Institute of Computer Science
  1. Courses
  2. 2023/24 fall
  3. Concurrent Programming Languages (LTAT.06.022)
ET
Log in

Concurrent Programming Languages 2023/24 fall

  • Pealeht
  • Loengud
  • Labs
  • Viited
  • Homework

This exercise implements the problem we used for Java in Python. The description is repeated here.

We want to find the number in a range of positive numbers which has the maximum number of divisors. A divisor is a number which divides another number with remainder 0. For example, 9 has two divisors, namely 3 and 1, whereas 8 has three, namely 1,2, and 4 (if the 1 is included or not does not matter for the maximum).

As a first step, write a program which finds the divisors for a number.

Then extend this to find the maximum number of divisors for a range in a sequential fashion. Try this out for eg the range from 1 to 1000 and 1 to 10,000. Record how long it takes for 1 to 10,000.

Finally, implement a concurrent version. Implementations using ThreadPoolExecutor from threading or ProcessPoolExecutor should look very similar. You can start with one of them and then change the code as needed for the other one. The implementation strategy can be similar to what we did in Java, i. e. write a function which finds the maximum for a range. Then write a program which uses this function with threading or multiprocessing to calculate the maximum for the range of 1 to 10,000. You can play with the number of threads/processes.

  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment