Menu
Topics Index
...
`

Highest Factor Of A Number Which In Turn Has Four Factors


If you need explanation Read this topic

If you need Answer Take test on this topic

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)
    {
    }
    
    public static int[] getFactors(int number)
    {
    }

}
Topic: Learn Arrays And Loops

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

here we need to find the factors for the give num..and among the factors we need to find highest factor which has exactly 4 factors..

* take an for loop and initialize to input/2 and condition>=1
* now check if the i is factor to the input than start an loop j=1 and j<=i now check if the i%j==0 than increase the count...after coming out of the loop check if the count==4 than return i;

Note: here we are taking i=input/2 Bcz here they aasked highest factor thats y are coming from the back..

Posted by Uday Kumar    2015-01-29 14:41:24


This dose is now closed and the winners are Uday Kumar,  for 'First Correct Comment', Uday Kumar,  for 'Second Correct Comment'. The 'lucky liker' is Bhagi Bhagyasri. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2015-01-31 04:18:06


© meritcampus 2019

All Rights Reserved.

Open In App