Write a program to get the highest factor of a number, which in turn has exactly four factors.
Input (Number) | Output (Number) |
---|---|
15732 | 437 (437 is a factor of 15732 and it has exactly four factors 1, 19, 23 and 437) |
5525 | 221 (221 is a factor of 5525 and it has exactly four factors 1, 13, 17 and 221) |
65025 | 85 (85 is a factor of 65025 and it has exactly four factors 1, 5, 17 and 85) |
class HighestFactorOfNumber
{ public static void main(String s[])
{
int inputNumber = 5525;
int factor = highestFactor(inputNumber);
System.out.println("The highest factor of 5525 which exactly has four factors is " + factor);
}
public static int highestFactor(int input)
{
//Write a code here to get the number as per the requirements above and return it. If required, you can use getFactors method.
}
public static int[] getFactors(int number)
{
//Write a code here to calculate the factors of a given number and return it.
}
}
Topic: Learn Arrays And Loops