Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEEDED IN C++. As you recall, a prime number is a positive integer that is evenly divisible only by 1 and itself. A semi-prime is

NEEDED IN C++. As you recall, a prime number is a positive integer that is evenly divisible only by 1 and itself. A semi-prime is a number that is the product of two prime numbers and is evenly divisible only by 1 and these two prime numbers. Semi-primes are used in various encryption schemes and are, therefore, of interest to computer scientists. We will write a program to find all of the semi-primes less than 100,000,000. To do this, you will write and use the following functions. You must not use any built-in functions. unsigned numFactors ( unsigned long UL); This function will take an unsigned long, UL and return the number of factors that are less than UL. If you are bored with this assignment, write the function recursively. unsigned nthFactor ( unsigned long UL, unsigned n); This functions will take an unsigned long, UL and return the nth factor of that number. The factor will always be less than UL. Note: the only factor less than a prime number is 1. The first factor will always be the number one. If the number is even, the second factor will always be two. If n is too large or if n is zero, the function will return zero. For example, if UL is 8 the factors are: 1, 2, and 4. if you use a value greater than 3 for n your function must return 0. If you are bored with this assignment, write the function recursively. bool isPerfectSquare ( unsigned long UL ); This functions will take an unsigned long, UL and return true if UL is a perfect square bool isPrime ( unsigned long UL); This functions will take an unsigned long, UL and returns true if the number is prime. You must use numFactors to implement this function. bool isSemiPrime ( unsigned long UL); This functions will take an unsigned long, UL and return true if UL is a semi-prime. A semi-prime is a number that is the product of two prime numbers. For example, 6 is a semi-prime and 9 is, also. You must use your other functions to implement this function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions