728x90
/**
factorual
[다음]
input number(2~9)? 5
1 * 2 * 3 * 4 * 5 = 결과
*/
class Assignment2
{
public static void main(String[]args) throws Exception{
int fac,result=1;
while(true)
{
System.out.print("\nInput number(2 ~ 9)? ");
fac=System.in.read()-'0';
System.in.read();
if(fac<2 || fac>9)
System.out.println("Input Error!\nTry Again!");
else break;
}
for(int i=1;i<=fac;i++)
{
result*=i;
System.out.print(i);
if(i==fac) System.out.print(" = "+result);
else System.out.print(" * ");
}
}
}
728x90