我試圖編寫代碼的階乘數程序,下面的代碼錯誤顯示在(INT I = N;我> 0;我 - )
public class Factorial {
public static void main(String[] args) {
Scanner in = new Scanner(System. in);
System.out.println("Enter the number whose factorial you want: ");
int n = in .nextInt();
int f = 1;
for (int i = n; i & gt; 0; i--) //error show what's wrong in for loop {
f = f * i;
}
System.out.println("Factorial of " + n + " is " + f);
}
}
你從什麼地方有複製粘貼代碼。所以'>'appare而不是'>'。 – Manwal