Sunday, September 11, 2016

SE475 - Fibonacci Program

What's up everybody!

After the setup now finally comes my favorite part, coding!!

Fibonacci program development

This really wasn't hard, all I did was create a static int function named Fibonacci, takes an int as parameter and it is called in main. I thought of having the user input the numbers, but ultimately I just decided to go for the default numbers in the homework, 15 and 22.  The function checks if the given integer is equal or less than 2, if it is, it simply returns 1. But if it's bigger than 2, then the function calls itself two times, one with n-1 and the other with n-2, where the returned values are summed up (Fibonacci(n-1) + Fibonacci(n-2)). Not much else to add other than I successfully uploaded it to Perforce.

Note to self: whenever I create a new project, upload it immediately to Perforce! Don't wait until it's ready and upload it in one go. Remember to keep checking-in updates as much as possible, to have a better chance of having a good backup and not do everything all over again.

Feels good to code native C# again, I'm used to coding C# only in Unity, so this is a nice change of pace.

I'll keep you posted, but until then, back to work!

No comments:

Post a Comment