Problem 2 - Computing prefect numbers A positive integer is called a perfect number if it is equal to the sum of all of its positive divisors, excluding itself. For example, 6 is the first perfect...


Problem 2 - Computing prefect numbers<br>A positive integer is called a perfect number if it is equal to the sum of all of its positive<br>divisors, excluding itself. For example, 6 is the first perfect number because 6 = 3 +2 + 1.<br>(The same applies for 28 1+2 + 4+7+14).<br>Write a program that creates an array of N integers (N = 3000) and fills it with random<br>numbers between 1 and 200. The program has to count the number of perfect numbers in<br>this array. To do that in less time, it breaks down the job between three threads:<br>1. threadLow: counts perfect numbers in the first part of the array. (From 0 up to<br>1000)<br>2. threadMiddle: counts perfect numbers in the second part of the array. (From 1000<br>up to 2000)<br>3. threadHigh: counts perfect numbers in the third part of the array. (From 2000 up to<br>3000)<br>The parent (main) thread waits for them to finish, calculates the sum of the three values,<br>and prints it. Note that the three threads have similar jobs to perform with some<br>differences regarding the range of search in the array.<br>

Extracted text: Problem 2 - Computing prefect numbers A positive integer is called a perfect number if it is equal to the sum of all of its positive divisors, excluding itself. For example, 6 is the first perfect number because 6 = 3 +2 + 1. (The same applies for 28 1+2 + 4+7+14). Write a program that creates an array of N integers (N = 3000) and fills it with random numbers between 1 and 200. The program has to count the number of perfect numbers in this array. To do that in less time, it breaks down the job between three threads: 1. threadLow: counts perfect numbers in the first part of the array. (From 0 up to 1000) 2. threadMiddle: counts perfect numbers in the second part of the array. (From 1000 up to 2000) 3. threadHigh: counts perfect numbers in the third part of the array. (From 2000 up to 3000) The parent (main) thread waits for them to finish, calculates the sum of the three values, and prints it. Note that the three threads have similar jobs to perform with some differences regarding the range of search in the array.

Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here