Problem A
Divisible by
If you are doing this problem outside of a class, or your instructor has not given you code to use as a starting point, skip ahead to the Input/Output sections for a concise description of the input/output requirements of this problem.
CS 121 students: To solve this problem, use file hw/divisibleby/divisibleby.py from your CS 121 repository as a starting point. It will handle the input/output, and all you will need to do is insert code at line 8.
Assume m, n, p and q are variables with integers. Replace the comment # YOUR LOOP GOES HERE with a loop that computes the sum of the values between m and n inclusive that are divisible by both p and q.
If you are using divisibleby.py as a starting point, you can ignore the rest of the Input/Output sections below. Just submit your modified divisibleby.py once you have written your solution.
Input
The input is four integers: $m$, $n$, $p$ and $q$, each separated by a single space. The bounds of the numbers is: $-100 \leqslant m,n,p,q \leqslant 100$.
Output
Print the sum of the values between $m$ and $n$ inclusive that are divisible by both $p$ and $q$.
Sample Input 1 | Sample Output 1 |
---|---|
0 10 2 3 |
6 |
Sample Input 2 | Sample Output 2 |
---|---|
0 20 2 3 |
36 |
Sample Input 3 | Sample Output 3 |
---|---|
0 10 3 5 |
0 |