• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HOW TO WRITE THE CODE WHICH calculate factorial of 10?

 
PANDORA HL
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
USED FO LOOP CODE
THANKS
 
PANDORA HL
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except that 0! = 1

Dave
 
David Weitzman
Ranch Hand
Posts: 1365
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic