Answer:
- Class is created with name PrimeFactorisation.
- isPrime(int num) is a method-> it will check whether the number given as a parameter is prime or not in time equal to O(sqrt(num)).
- printPrimeFactors(int num) -> a recursive method for printing the prime factors.
- Main method will be written to take a integer as input from user a.
We know that if a no x if divisible by y. than (y) and (x/y) are its factors and if they are prime numbers also , then they will be the prime factors.
Using this concept you can make recursive calls printPrimeFactors(y), printPrimeFactors(x/y).
Step-by-step explanation:
The code in java is explained below in image using comments before each statement.
The output image is also attached.