aspose file tools*
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: HOW TO WRITE THE CODE WHICH calculate factorial of 10?