public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
int number;
System.out.println("Enter a number to find the factorial of it: ");
number= sc.nextInt();
int factor=1;
if (number<0 && number>10)
{
System.out.println("Invalid!! the number has to be between 1 and 10");
}
for(int x=1; x<=number; x++)
{
factor = factor*x;
System.out.println("The factorial of "+number+" is = " +factor);
}
}
내 코드 @TNT를 확인할 수 있습니까? 그건 경우 u는 나를 여기함수 및 프로 시저 사용 적용
예 = 1 * 2 * 3 * 4 * 5 –
내가 할 것 어떻게, 내가 사촌 우리는 함수를 사용하여 계승을 사용할 수 있습니다. –
@Makoto : 알고리즘이 정확합니다. System.out 문은 매 반복마다'number'보다는'x'를 반영해야합니다. – Voicu