--Originally published at Tec Life
Well, I do no what is a factorial….
So in order to solve this problem I search on the most trusthly page on internet… Wikipedia, then I notice that a factorial is :
In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,
- 5!=5×4×3×2×1=120.
So the problem was this:
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).
And then to solve this problem I put my normal main and later I do my function that says that is going to start in 1 because cero isn’t important, so while c is less than 1 is going to sum 1 till reach that number that the user input, and then is going to return me the new value that is going to be a or the result :).
Image from: http://weknowmemes.com/2012/07/fuck-you-science/http://giphy.com/gifs/math-zach-galifianakis-the-hangover-5yLgoczEvFoE5LyoiZO