Question: python programming MEDIUM-1 John is a brave adventurer who just entered a mysterious cell to find a legendary treasure. The cell is filled with traps,

python programming

python programming MEDIUM-1 John is a brave adventurer who just entered a

mysterious cell to find a legendary treasure. The cell is filled with

traps, monsters, and hidden treasure boxes kept at some blocks. John can

MEDIUM-1 John is a brave adventurer who just entered a mysterious cell to find a legendary treasure. The cell is filled with traps, monsters, and hidden treasure boxes kept at some blocks. John can either move in forward or backward directions. The first stage of the cell is a dark and narrow corridor, where John needs to collect a gold coin to unlock the door to the next stage. Gold coins are hidden in some of the treasure boxes. Treasure boxes are kept in blocks whose block number is a number that is greater than 1 and is not divisible by any number other than 1 and itself. John has a map that shows the blocks of the treasure boxes, but the map is not very detailed. Hence, help him find the block of the nearest treasure box to collect the gold coin. Given a number N that represents the block number where John is standing. Write a program that reads the number N representing the block number of John and prints the block number that is nearest to John's block number. If multiple treasure boxes are at the same distance forward direction to him (block number that is greater than John's block number). Note If multiple treasure boxes are at the same distance from John's block number, print the block number that is in forward direction to him (block number that is greater than John's block number). Input The input will be a single line containing an integer N representing the block number of John. Output The output should be a single line containing an integer representing the block number of the nearest treasure box. Explanation For example, if the given block number N=25, - The treasure box that is nearest to John in the forward direction is at block number 29 . - The treasure box that is nearest to John in the backward direction is at block number 23. - The treasure box that is nearest to John is in block number 23 (2523

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!