Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

help with factorial program

807589Apr 13 2008 — edited Jan 9 2009
so im trying to write a program that gives me the factorial of a number, but i can't seem to get it to work i 've looked all over but it doesn't seem to help.

please help me figure out what i need to do to my code to make it print out the factorial of the number. right now i can make it print out basically a multiplication table of the number i enter, how can i add the numbers together to get the factorial? or what can i do with my code to make it work?

thank you for the help.

   public static void main(String[] args){

int number = Console.readInt("Enter number ");
int count = 0;
int factorization = 0;


if (number<=1)
System.out.println ("Answer is 1");
else
count = number -1;
 while (count>1)
{
	
	factorization = number * count;
System.out.println(factorization);
count = count - 1;



}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 6 2009
Added on Apr 13 2008
27 comments
521 views