This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes HOW TO WRITE THE CODE WHICH calculate factorial of 10? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HOW TO WRITE THE CODE WHICH calculate factorial of 10?" Watch "HOW TO WRITE THE CODE WHICH calculate factorial of 10?" New topic
Author

HOW TO WRITE THE CODE WHICH calculate factorial of 10?

PANDORA HL
Greenhorn

Joined: Jul 23, 2001
Posts: 5
USED FO LOOP CODE
THANKS
PANDORA HL
Greenhorn

Joined: Jul 23, 2001
Posts: 5
I got it
public class jiecheng {

public static void main(String args[]){
double y;
y=1;
for(double i=2;i<10;i++){

y=i*y;
System.out.println("factorial of 10="+y);
}

}
}
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Except that 0! = 1

Dave
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
Here it is:
System.out.println("10! = " + (3628799 + 1));
By the way, you'll need to replace 'i<10' with 'i<=10'
[This message has been edited by David Garland (edited August 24, 2001).]
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: HOW TO WRITE THE CODE WHICH calculate factorial of 10?
 
It's not a secret anymore!