//CFAN 2002 ,Y"jH8jz
//递归算法 :v1~eDpy
//求阶乘 )U.e u!
import java.io.*; j[8;&H?
public class DiGui @,c2TwW
{ VO;!Xt(PB
public static void main(String args[]) | K3=+{
{ wDGIGF#Q
int i=0; BlRDf-.V
char ch=' '; \dm,plxo.
String s; $S ae2
Child ren=new Child(); a:C_$Xb
try Tf?6:n
{ fj}JvvJ
System.out.println("Please intput a Number,End whit '#'"); , H r#[]=
do =(|!ZR
{ +EaQQ bg
BufferedReader br=new BufferedReader(new InputStreamReaderSystem.in)); W+kDA9`,
[PO+sTd~k
s =br.readLine(); %~XY;N{BJ
i=Integer.parseInt(s); L5CLj=<E
System.out.println(ren.Factorial(i)); 1 7=5;m
} *#T8_I_Kg
while(ch!='#'); q!jl w]OJ
}catch(IOException e){} 9Ot6Flq
} GkjLdowpA
} SgQ?#(f
tMq*uUdR,
class Child w>ZjH
{ XhPg|O
3BDOi&s0
double Factorial(int n) #Z?0nmk]$
{ Ta[^2+ U%
if (n==1) cPjCZ; P
return 1; v#vdy\KIV
else 9gY5:Zc
return n*Factorial(n-1); 7<1AV]
} !@u )LCb
}
查看本文来源