I am new to Java. I am trying to find the factorial of a number using Scanner. I am getting an error at p as p cannot be resolved to a variable. What does it mean?
import java.util.Scanner;
public class fact {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner object = new Scanner(System.in);
System.out.println("enter a number:\n");
int i = object.nextInt();
int result = 1;
for (p = 1; p <= i; p++) {
result = result * 1;
System.out.println("factorial of a number is:result");
}
}
}