Find Jobs
Hire Freelancers

C# Program

$10-30 USD

In Progress
Posted about 6 years ago

$10-30 USD

Paid on delivery
Write a multithreaded solution for this problem. You are asked to find the integer in the range 1 to MAX that has the largest number of divisors. MAX should be a fixed constant declared at the top of your code no smaller than 20,000 and hopefully something like 100,000 or 200,000 (depending upon the speed of your computer). Your program must create K threads (a fixed constant declared at the top of your code) that deal with separate ranges of integers. For example, if MAX is 1000 and K is 10, then the threads would deal with the ranges 1..100, 101..200, 201..300, etc. You can assume that K evenly divides MAX so that each of the ranges contains the same number of integers. (You might consider how to deal with the situation when K does not evenly divide MAX.) When your program concludes it must display: • the values of MAX and K; • all the integer(s) that have the largest number of divisors (frequently there will be several integers having the same largest number); • a count of how many divisors there are; • the total elapsed time for the entire computation. Test your program with several values for MAX and K to be certain that it functions properly. Discussion Here is some pseudocode for solving a portion of this problem without using threads: maxDivisors = 0 // Maximum number of divisors seen so far for N from 1 to MAX: let count be the number of divisors of N if (count > maxDivisors): maxDivisors = count // New maximum number of divisors whichInt = N // The integer that gave the maximum You would need to add pseudocode to handle the issue of remembering each of the values of N that have maxDivisors number of divisors. You might use a List for this purpose. To turn this into a multithreaded program, we have to divide the integers between 1 and MAX into groups and assign each group of integers to a thread. In its run method, each thread finds the maximum number of divisors for integers in its assigned group as well as the values of N having this many divisors. The only problem is combining the final results of all the threads. To solve this problem, you might have each thread record its results when it concludes by calling an appropriately synchronized method. As a check: For integers between 1 and 20,000 the maximum number of divisors is 80 The 2 numbers that have 80 divisors are 15,120 18,480 For integers between 1 and 200,000 the maximum number of divisors is 160 The 2 numbers that have 160 divisors are 166,320 196,560
Project ID: 16726764

About the project

4 proposals
Remote project
Active 6 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
4 freelancers are bidding on average $33 USD for this job
User Avatar
Hello , I am experienced c# algorithm developer. I can help you with this task. Looking to hearing from you soon.
$30 USD in 1 day
4.8 (54 reviews)
5.4
5.4
User Avatar
Hello, I am interested in this project and so wanted to discuss more it in details. I have good experience in C# programming. I will provide you quality work according to your instrument. Thanks
$45 USD in 1 day
4.8 (58 reviews)
5.4
5.4

About the client

Flag of UNITED STATES
SEWARD, United States
5.0
3
Payment method verified
Member since Apr 17, 2018

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.