Question: Write a method that will determine whether an input integer has three prime factors. 1. Try to divide by 2 if true counter++ 2.

Write a method that will determine whether an input integer has three prime factors. 1. Try to divide by 2 if

Write a method that will determine whether an input integer has three prime factors. 1. Try to divide by 2 if true counter++ 2. A loop from 3 to n/2 (+2): m If m is prime n%m == 0 Counter++ a. b. c. If the value of counter is higher than 3 d. Return false (or break) 3. If the value of counter is 3 then return true 4. Else return false public static boolean triPrimeFactors (int num) { int counter = 0; if (num%2== 0) counter++; for (int i = 3; i < int(num/2)+1; i = i+2) { } if (num % i == 0 && isPrime(i )) counter++; if (counter > 3) return false; } if (counter == 3) return true; else return false; } public static boolean triPrimeFactorsV2 (int num) { int counter = 0: if (num%2== 0) counter++; int i =3: while (i < int(num/2)+1) { if (num % i == 0 && isPrime(i)) counter++; if (counter > 3) return false; i=i+2; } if (counter == 3) return true; else return false:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Method 1 triPrimeFactors java public sta... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!