i wonder why that the highlighted part doesnt work for number 24?
it works fine when i enter 6.
Code:import java.util.Scanner;
public class sample{
public static void main (String[]args){
Scanner input = new Scanner(System.in);
System.out.println("Enter a positive integer number");
int num1 = input.nextInt();
System.out.println("Enter a positive integer number");
int num2 = input.nextInt();
int max = 1;
if (num1 >= num2){
max = num1;
}
else if (num1 <= num2){
max = num2;
}
System.out.println("The max is: "+ max);
//factorial
int total = 1;
if (max <=8){
for(int fac = max; fac >= 1; fac--){
total = total*fac;
}
System.out.println(max+"!"+ "is " + total);
}
[COLOR="Teal"]//check if max is factorial of any number
int total1 = 1;
for (int tri = 1; tri<max; tri++){
for (int fac1 = tri; fac1 >= 1; fac1--){
total1 = total1 * fac1;
if (total1 == max){
System.out.println(max+" is the factorial of "+ tri);
}
}
}[/COLOR]
int sum = 0;
//perfect number
for (int per = 1; per < max; per++){
if( max % per == 0){
sum = sum + per;
}
}
if (sum == max){
System.out.println( max + " is a perfect number");
}
else
System.out.println(max + " is not a perfect number");
}
}

