What to Do

creative commons licensed (BY-SA) flickr photo by ▓▒░ TORLEY ░▒▓: http://flickr.com/photos/torley/3505324528

creative commons licensed (BY-SA) flickr photo by ▓▒░ TORLEY ░▒▓: http://flickr.com/photos/torley/3505324528

Create a program that asks the user for a non-negative integer (let’s call that number n) and display for them the value of n! (n factorial).

After showing them the answer, ask them if they would like to try another number (with a simple y/n response) and either ask again (for y) or quit the program and wish them a nice day (if they answered n).

Details

For the Python group, resist the urge to call math.factorial(n). Yes that would solve the problem but what would we do if there was no math.factorial() and we had no internet to find someone’s solution?

There are two basic approaches: a loop with an accumulator of the multiplication and a recursive solution. Choose one and implement that. Once that is done, try the other way.

If you used a while loop for the solution with a loop, try structuring this with a for loop (or vice-versa).

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag WSQ09 on your post so our blog hub picks that up.

You should include your code as a link to GitHub. You really should start using your GitHub repository now. If you need help on that, just ask Ken or your classmates.

If you have not seen my video yet about the GUI tutorial for GitHub, go check that out: http://youtu.be/YQmlksGFZWY

And of course, leave any questions here as well as asking those questions on Twitter with the hashtag #TC1014 so we all see your question posted there.

CC BY 4.0 WSQ09 – Factorial Calculator by Ken Bauer is licensed under a Creative Commons Attribution 4.0 International License.