AIOC Banner

Problem: Bugs

Want to try solving this problem? You can submit your code online if you log in or register.


Input File: bugsin.txt
Output File: bugsout.txt
Time Limit: 1 second

You do not like bugs. This is unfortunate, since your town has been taken over by a plague of small insects. Thankfully these insects only come out every seven years — they appear all over town, make very loud noises for a few months, lay their eggs and then disappear, until a new generation of insects emerges from the eggs seven years later and the cycle starts over again.

It is well known that the insects only emerge during years that are exact multiples of seven. For instance, they appeared in the years 1995 and 2002 (since 1995 = 7 x 285 and 2002 = 7 x 286). You do a quick calculation and deduce that they will reappear in the year 2009. Flipping your calendar several years forward, you start making your plans for a very long holiday.

You must write a program to help you and your townsfolk plan ahead for the appearance of these insects in years to come. Your program must read in a year and output the first year after that in which the insects will emerge.


The input will consist of a single line containing a single integer. This integer will represent a year, and will be between 1 and 10,000 inclusive.


Your output should consist of a single line containing a single integer. This integer must be the first year after the input year in which the insects will reappear.

Sample Input 1


Sample Output 1


Sample Input 2


Sample Output 2



The score for each input file will be 100% if the correct year is written to the output file and 0% otherwise.


Privacy statement
© Australian Mathematics Trust 2001-2023

Page generated: 25 March 2023,  6:53pm AEDT