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 , the newly elected mayor announced the appointment of the new treasurer, a new dog-catcher and congratulated the chief programmer for winning the recent election. That is, all positions were changed over. This is highly unusual. You will quantify how unusual this really is.
Write a program that inputs the year and the future year and lists all years between and inclusive when all positions change.
Sample Input
2004
2100
Sample Output
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 2^2 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 :))
Hello