Write a program to find all prime factors of a given number. A prime factor is an integer that is a factor and is also a prime. Prime factors have many applications in the field of security and...


Write a program to find all prime factors of a given number. A prime factor is an integer that is a factor and is also a prime. Prime factors have many applications in the field of security and cryptography. In writing your program, feel free to use the ideas presented in PRG-8 and PRG-9.


PRG-8


Write a program that finds all the factors of a given number. A factor is a number less than or equal to the given number that divides the number with remainder zero. Note that any number has at least two factors: 1 and itself. Test your function with the factors of a few numbers and tabulate the results in a program. Write a recursive (helper) function that finds the divisor of two numbers. Then use a no recursive function to call it.


PRG-9


Write a tail recursive function and the corresponding no recursive function to test if an integer is prime. Remember that a prime number is only divisible by 1 and itself, but we can check the numbers from 1 to the square root of that number to be sure that it is prime. Remember that 1 is not a prime. Mathematicians divide the positive integers into three groups: composite, prime, and 1.

Nov 18, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here