UKSPC Practice Problems » Tickets
 Source

driver.c
,driver.cpp
, ordriver.java
 Input
 standard input
 Output
 standard output
You have an infinite line of people, who are numbered with natural numbers, 1 through infinity. But tickets are not given out strictly FIFO, but in rounds. In round 1, the first person is given a ticket. In all subsequent ith rounds, the first person in line and every ith person after them is given a ticket. Once you have a ticket, you are removed from the line. Given a natural number n < MAX_INT, report the (ordinal) number of the first person to receive a ticket in the nth round.
Sample Input
5
Abbreviated Sample Output
7