Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## 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.

3. ## 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;

4. ## Re: 0-10Factorial table

What are you stuck on? Figuring out the algorithm for factorials or how to put it to code?

5. ## Re: 0-10Factorial table

how to put it to code

6. ## Re: 0-10Factorial table

Are you looking for a recursive solution our something straight forward?

7. ## Re: 0-10Factorial table

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.

8. ## 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?

9. ## Re: 0-10Factorial table

I do not have the right iterative factorial algorithm

10. ## 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.

11. ## Re: 0-10Factorial table

I'm good, thanks for your help!

12. ## Re: 0-10Factorial table

s
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..

13. ## Re: 0-10Factorial table

thanks u

--- Update ---

Originally Posted by depsai
thanks u
fvdxbvcvb