Cheeky bus driver

0

The bus driver picks up the children from their homes every morning for school. All the homes are positioned around a circular street and the bus driver has to stop at every home exactly once.

One monday morning the bus driver decided to only pick up every second child he encountered along his way. However, he still had to pick up every single children, so this meant he was willing to go multiple rounds.

The houses are indexed from 1 to N (they come in order). The bus driver starts at the first (index 1) house and does not change directions during his trip. You must find the index of the house the last child is picked up from.

Input

A single positive number N read from the standard input representing the number of houses along the street.

Output

Output the index of the house the last child is picked up from to the standard output.

Example

Input: 10

Output: 4

The order of pickups are as follows: 1 3 5 7 9 2 6 10 8 4

Shortest code wins!

Tom

Posted 2017-04-13T15:06:57.323

Reputation: 1

Question was closed 2017-04-13T15:21:58.377

Why the restrictive input/output? It is common to allow anonymous functions that take an argument as input and return a value as output, as well as STDIN and STDOUT. – Comrade SparklePony – 2017-04-13T15:08:45.593

This is a special case of this challenge, but since this problem has a closed form solution for k = 2, it might be worth keeping this open separately.

– Martin Ender – 2017-04-13T15:12:15.840

1

@MartinEnder That makes it more of a dupe of this one, which is currently closed as a dupe of the other :/

– Geobits – 2017-04-13T15:18:19.927

I guess it's also subtly different because this one counts out the first in each pair, not the second. – Martin Ender – 2017-04-13T15:18:47.823

That's the same as the ninja challenge though. – Martin Ender – 2017-04-13T15:21:01.163

Next time, try posting in the sandbox first.

– Comrade SparklePony – 2017-04-13T15:42:26.147

No answers