A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
HOW TO WRITE THE CODE WHICH calculate factorial of 10?
PANDORA HL
Greenhorn
Joined: Jul 23, 2001
Posts: 5
posted
Aug 23, 2001 23:46:00
0
USED FO LOOP CODE
THANKS
PANDORA HL
Greenhorn
Joined: Jul 23, 2001
Posts: 5
posted
Aug 24, 2001 00:39:00
0
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
I like...
posted
Aug 24, 2001 00:55:00
0
Except that 0! = 1
Dave
David Weitzman
Ranch Hand
Joined: Jul 27, 2001
Posts: 1365
posted
Aug 24, 2001 06:38:00
0
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://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: HOW TO WRITE THE CODE WHICH calculate factorial of 10?
Similar Threads
onload
build.xml question
Why we live?
Netscape7.1 and window.createPopup()
input type=file
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter