Write a method that will determine whether an input integer has three prime factors. 1. Try...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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: 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:
Expert Answer:
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
Write a program that prints the calendar for a given year. The user will be promoted tochoose the calendar for the month or the year. If the year is selected, then the calendar for thegiven year will...
-
Write a JAVA program and include these methods. The method header is given. Invoke these methods from the main method. In the main you are to declare and create 2 integer arrays and 1 String array. ...
-
1. A projectile is launched in a vertical plane, at an angle 0 with initial velocity vo. It must be caught in a frictionless circular tube of radius R in such a way that the trajectory of the...
-
Pederson Enterprises produces giant stuffed bears. Each bear consists of $12 of variable costs and $9 of fixed costs and sells for $45. A wholesaler offers to buy 8,000 units at $14 each, of which...
-
The following data give the years of teaching experience for all five faculty members of a department at a university. a. Let x denote the years of teaching experience for a faculty member of this...
-
Describe in what ways the scope of nursing has changed.
-
The U.S. Department of Transportation provides the number of miles that residents of the 75 largest metropolitan areas travel per day in a car. Suppose that for a simple random sample of 50 Buffalo...
-
Martinez Ltd. had the following 2023 income statement data: Revenues $110,000 Expenses 50,900 $59.100 In 2023, Martinez had the following activity in selected accounts: Accounts Receivable Allowance...
-
How do blockchain designers increase the difficulty of block validation? What technique is employed by blockchains to ensure transactions cannot be changed? What type of internal control is a...
-
The data set Money has quarterly data on US money demand (more specifically, on demand for M1); the variables are described below. A money demand model is specified as following: log(ml,)=B, +B,...
-
Option Payoffs. Suppose that you wish to make a bet on Sofi Technologies (SOFI) as follows. You will (a) buy two calls on SOFI struck at $15 expiring on April 14, 2022, (b) sell six calls on SOFI...
-
Michael is 20 years old and currently studying at university. He works part time as a waiter and saves $210 per month from his wages. Michael has so far saved $5,000 with the aim of reaching $10,000...
-
ABC Motorworks Pte Ltd performs motor vehicle maintenance and repairs for its customers. The workshop keeps commonly used spare parts, but more specialised parts will be ordered from the distributor...
-
If you invest $7,200, what is your rate of return if you will receive the following cash flows at the end of these years: Yr. 1 - $1,500; Yr. 2 - $2,000; Yr. 3 - $2,000; Yr. 4 - $4,500? 2. What would...
-
Jones Computer Company acquired patent rights on January 2, 20Y8, for $2,000,000. The patent has a useful life of 10 years. On Jan 2, 20Y9, Dovetail Technologies successfully defended the patent in a...
-
7. Baladna wants to analyze process that includes delivery by suppliers, production inside the company, transportation to to its customers and information systems. Then it also wants to find out...
-
Under what circumstances will the image in a concave mirror be the same size as the object?
-
Find the magnitude of the electric force on a 2.0 C charge in a 100-N/C electric field.
-
You have 10 m of 0.50-mm-diameter copper wire and a battery capable of passing 15 A through the wire. What magnetic field strengths could you obtain (a) inside a 2.0-cm-diameter solenoid wound with...
-
Suppose a bond is taxable for both federal and state purposes. Let Rb = the BTROR on the bond, tfed = the federal tax rate, and tst = the state tax rate. Determine the ATROR (i.e., after federal and...
-
Under what conditions are the Exempt Model and Pension Model equivalent? Under what conditions would one model perform better than the other? How does the \($6,500\) limitation on deductible and Roth...
-
Harry wants to contribute either \($6,500\) (BT\($)\) to a traditional deductible IRA or \($6,500\) (AT\($)\) to a Roth IRA. His current tax rate is 30% for ordinary income and 15% for capital gains....
Study smarter with the SolutionInn App