Brain Teasers
Leap Year
The following task involves several steps, but they are out of order. Arrange them so that a person who follows the steps exactly can perform the task:
You want to be able to write "leap year" or "not a leap year" for any given year from 1801 to 2101, according to whether or not the given year had or will have 366 days in it. You must remember to take into account that years ending in 00 are leap years only if they are evenly divisible by 400 (thus, 1900 was not a leap year but 2000 was). Years ending in any other digits, of course, are leap years if and only if they are divisible by 4.
a) Divide the year by 100.
b) Divide the year by 4.
c) Read the year chosen (from 1801 to 2101).
d) Divide the year by 400.
e) Skip the next statement.
f) If there is a remainder, skip the next two statements.
g) If there is a remainder, skip the next two statements.
h) If there is a remainder, skip the next six statements.
i) Write "leap year."
j) Write "not a leap year."
k) End.
You want to be able to write "leap year" or "not a leap year" for any given year from 1801 to 2101, according to whether or not the given year had or will have 366 days in it. You must remember to take into account that years ending in 00 are leap years only if they are evenly divisible by 400 (thus, 1900 was not a leap year but 2000 was). Years ending in any other digits, of course, are leap years if and only if they are divisible by 4.
a) Divide the year by 100.
b) Divide the year by 4.
c) Read the year chosen (from 1801 to 2101).
d) Divide the year by 400.
e) Skip the next statement.
f) If there is a remainder, skip the next two statements.
g) If there is a remainder, skip the next two statements.
h) If there is a remainder, skip the next six statements.
i) Write "leap year."
j) Write "not a leap year."
k) End.
Answer
c) Read the year chosen (from 1801 to 2101).b) Divide the year by 4.
h) If there is a remainder, skip the next six statements.
a) Divide the year by 100.
f or g) If there is a remainder, skip the next two statements.
d) Divide the year by 400.
f or g) If there is a remainder, skip the next two statements.
i) Write "leap year."
e) Skip the next statement.
j) Write "not a leap year."
k) End.
Hide Answer Show Answer
What Next?
View a Similar Brain Teaser...
If you become a registered user you can vote on this brain teaser, keep track of which ones you have seen, and even make your own.
Solve a Puzzle
Comments hidden to avoid spoilers.
Follow Braingle!