Canadian Computing Competition: 2004 Stage 1, Junior #2
In CS City, a mathematical place to live, the mayor is elected every 4 years, the treasurer is appointed every 2 years, the chief programmer is elected every 3 years and the dog-catcher is replaced every 5 years.
This year, Year
Write a program that inputs the year
Sample Input
Copy
2004
2100
Sample Output
Copy
All positions change in year 2004
All positions change in year 2064
Comments
Reminder on how to find the LCM (Least Common Multiple)
First, find the prime factors of 2, 3, 4, 5
2^1 (2, on a theoretical paper, cross this out) 3^1 (3) 2^2 (4) 5^1 (5)
To find LCM, we need the highest power of each prime factor.
In this case, the highest power of,
2 is 2, between 2^1 and 2^2 3 is 1, between 3^1 and nothing 4 is 1, between 4^1 and nothing 5 is 1, between 5^1 and nothing
Now to find LCM, 3^1 x 2^2 x 5^1 = 60
Therefore the LCM of 2, 3, 4, 5, is 60 (I have no idea why the comment looks so different than what it's supposed to look like)
thank you, really helpful :))