日期:2014-05-20  浏览次数:20744 次

循环语句for
import java.util.Scanner;                           
import java.math.BigInteger;                        
public class T5                                     
{                                                   
public static void main(String[] args)            
{                                                 
int a;                                          
int b=1;                                        
System.out.println("请输入要求阶乘的数:");      
Scanner sc=new Scanner(System.in);              
a=sc.nextInt();                                 
BigInteger d=BigInteger.valueOf(1);             
do                                              
{                                               
d=d.multiply(BigInteger.valueOf(b));          
b++;                                          
}while(b<=a);                                 
System.out.println("所求的数的阶乘是:"+d);    
}                                               
}