Question
John the Postman became bored one night, and to break the monotony of the night shift, he carried out an experiment with a row of
John the Postman became bored one night, and to break the monotony of the night shift, he carried out an experiment with a row of mailboxes in the post office. These mailboxes were numbered 1 through 150, and beginning with mailbox 2; he opened the doors of all even-numbered mailboxes. Next, beginning with mailbox 3, he went to every third mailbox, opening its door if it was closed and closing its door if it was opened. Then he repeated this procedure with every fourth mailbox starting at mailbox 4, then every fifth mailbox, and so on. When he finished he was surprised at the distribution of opened and closed mailboxes. Write a program to determine which mailboxes are opened and which ones are closed, and output the results neatly in a table format. Assumption: all mailboxes are initially closed
sample output format 1 opened 2 opened 3 closed 4 closed 5 opened 6 opened. 7-opened 8 closed 9 closed 10 closed 11 closed 12 closed 13 closed 14 opened 15 F closed. (BTW: results above are incorrect to demonstrate output format only)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started