Question: Develop a multithreaded integer factorization program in C++ In number theory, integer factorization is the process of breaking a composite number into a product of

Develop a multithreaded integer factorization program in C++

In number theory, integer factorization is the process of breaking a composite number into a product of two smaller integers. If these factors are further restricted to prime numbers, the process is called prime factorization https://en.wikipedia.org/wiki/Integer_factorization

Prime check

Note that a number n is considered prime if it does not have any factors in the range 2 to (inclusive). The program will be supplied with 1 or more numbers(use C++ data type unsigned long long int) to be factorized as command-line arguments. Each number should be processed in the following manner

Base case

  1. If the number itself is prime (i.e., it cannot be factorized) then just print Is already prime as shown in the first sample output below.
  2. if the number is not prime, then print the two factors with one of them being the first smallest factor. In addition, indicate if the factors are prime by printing (prime) after the factors.

Outputs example

$ ./prime 78167

78167: Is already prime.

$ ./prime 18446744073709551614 18446744073709551614 = 2 (prime) * 9223372036854775807

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!