# 0-10Factorial table

• April 9th, 2013, 11:00 PM
my21
0-10Factorial table
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.
• April 10th, 2013, 06:13 AM
Norm
Re: 0-10Factorial table
• April 10th, 2013, 07:52 PM
my21
Re: 0-10Factorial table
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;
• April 10th, 2013, 08:07 PM
Chris.Brown.SPE
Re: 0-10Factorial table
What are you stuck on? Figuring out the algorithm for factorials or how to put it to code?
• April 10th, 2013, 10:05 PM
my21
Re: 0-10Factorial table
how to put it to code
• April 10th, 2013, 10:24 PM
Chris.Brown.SPE
Re: 0-10Factorial table
Are you looking for a recursive solution our something straight forward?
• April 11th, 2013, 10:00 AM
my21
Re: 0-10Factorial table
Quote:

Originally Posted by Chris.Brown.SPE
Are you looking for a recursive solution our something straight forward?

something straightforward, i'm pretty sure the recursive way needs the method to be an integer but that requires return statements.
• April 11th, 2013, 10:29 AM
Chris.Brown.SPE
Re: 0-10Factorial table
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?
• April 11th, 2013, 11:52 AM
my21
Re: 0-10Factorial table
I do not have the right iterative factorial algorithm
• April 11th, 2013, 12:08 PM
Chris.Brown.SPE
Re: 0-10Factorial table
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.
• April 11th, 2013, 01:29 PM
my21
Re: 0-10Factorial table
I'm good, thanks for your help!
• April 17th, 2013, 12:21 AM
depsai
Re: 0-10Factorial table
s
Quote:

Originally Posted by my21
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;

--- Update ---

thanks.... it help me lot..