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.
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
Members have full access to the forums. Advertisements are removed for registered users.
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.
If you don't understand my answer, don't ignore it, ask a question.
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?
Writing code is your job, helping you fix and understand it is mine.
<-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!
how to put it to code
Are you looking for a recursive solution our something straight forward?
Writing code is your job, helping you fix and understand it is mine.
<-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!
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?
Writing code is your job, helping you fix and understand it is mine.
<-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!
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.
Writing code is your job, helping you fix and understand it is mine.
<-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!
I'm good, thanks for your help!