# A New Joseph Problem

Newman and Bamboo are good friends. One day, Newman taught Bamboo the famous Joseph Problem: there are N persons numbered 1 to N standing round a circle. They stand clockwise according to their numbers (namely 1, 2, 3, 4, …, N). Then, starting from 1, the killer kills every 2nd person he counts until there is only one person left whose number is J(N). We can easily infer that J(1) = 1, J(5) = 3 and J(6) = 5. Bamboo finds this problem intriguing and starts thinking. Suddenly, he finds that if he continually uses J(N) to be the term in J, he can finally get a fixed number. For example, J(2) = 1, so J(J(2)) = 1, J(J(…J(2)…)) = 1. Newman agrees with Bamboo but Bamboo is not satisfied. Furthermore, Bamboo wants to know what the fixed number will be for a specific N. Can you help us?

Only one line containing n (1 ≤ n ≤ 1010000).

Only one line containing K such that J(J(J(J…J(N)…))) = K and J(K)=K.

10

3

• 写回答

#### 1条回答默认 最新

• threenewbee 2016-12-29 16:57
关注
本回答被题主选为最佳回答 , 对您是否有帮助呢?
评论

#### 悬赏问题

• ¥15 MATLAB动图问题
• ¥15 有段代码不知道怎么理解，const isToken = (config.headers || {}).isToken === false
• ¥100 采用栈和深度优先算法对我的代码进行修改显示路径
• ¥15 pointnet2包安装
• ¥20 射频功率问题，解答者有酬谢！
• ¥80 构建降雨和积水的预测模型
• ¥15 #Qt Transform setTransform()在鼠标拖动移动视角是一致在原地不动，无法变换视角（细微观察似乎视图有在原地抖动），无法变换视角（细微观察似乎视图有在原地抖动）
• ¥50 如何利用无人机拍摄的数码照片测量鸟卵的长短径
• ¥100 github贡献者给与奖励
• ¥15 使用DS18B20+ESP8266获取温度数据返回-127.00