How can I make a factorial table for the numbers 0-10...I want it printed so 0 1, 1 1, 2, 2, 3 6 etc, but I do not know how.
Printable View
How can I make a factorial table for the numbers 0-10...I want it printed so 0 1, 1 1, 2, 2, 3 6 etc, but I do not know how.
This is only for the numbers 1-30, but I don't know how to calculate its factorial and match it up with the given integer.
public static void factorial() {
int sum, number = 10;
for (int i = 1; i <= number; i++)
{
System.out.print(i + "\t");
sum = 1;
What are you stuck on? Figuring out the algorithm for factorials or how to put it to code?
how to put it to code
Are you looking for a recursive solution our something straight forward?
Ok, so you're trying to write an iterative (non-recursive) factorial program. If you have the iterative factorial algorithm, which part is causing you problems? Or do you not have an iterative factorial algorithm?
I do not have the right iterative factorial algorithm
A factorial is simply the number multiplied by all numbers previous to it.
8! = 8*7*6*5*4*3*2*1 or 1*2*3*4*5*6*7*8
Looks like a simple for loop to me. Google "iterative factorial algorithm" if you're still having issues with the algorithm after seeing this explanation.
I'm good, thanks for your help!