Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to create a program based on these specifications, I think it would

ID: 3889978 • Letter: I

Question

I am trying to create a program based on these specifications, I think it would be very useful to have someone more experienced with C++ to show me a code that I can reflect on and help me work on mine. I am not looking to copy and paste someone elses code.... I am trying to learn this by writing my own program, but I think I can learn more easily by looking at sample code and figuring out how it's working, so that I can work on mine. Giving good ratings for helpful insight. **When I run my current code, I can pass most test cases but when I pass a huge number, I get an "error in processing" and it times out. I'm not sure how to fix this so please try to test a very large number to make sure the code can run with one.

function: biggest_prime: return is long. Argument is a single long n. Returns the largest prime factor of n. function: sum of divisors: return is long. Argument is a single long n. Sums up all the divisors of the argument n and returns that sum function: k_hyperperfect: return is long. Arguments are: · long n. The number we are checking long k_max. The maximum k value considered. The algorithm searches for a k from 1 up to and including k_max to test if the input number n isk- hyperperfect for that k. The first k in the range 1 to k max is returned where the input n proves to be k-hyperperfect. If n is not k-hyperperfect for any k from1 to k_max, the function returns 0. k_hyperperfect should utilize sum of_divisors in its calculations. function: b_smooth: return is bool. Argument are: long n. The number being checked · long b. The prime factor being checked. Returns true if the input n is b smooth, false otherwise. b smooth should utilize biggest prime in its calculations.

Explanation / Answer

Biggest prime.

In your approach large input won't work properly as your method will take too much time to evaluate the answer.

another more optimized approach is this. i am writing my code in java and i will explain it also.

public static int largestPrimeFactor(long number)

{

int i;

long copyOfInput = number;

for (i = 2; i <= copyOfInput; i++)

{

if (copyOfInput % i == 0)

{ copyOfInput /= i;

i--;

}

}

return i;

}
This code will get to the answer for large inputs as well.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote