The Collatz Code
来源:互联网 发布:关于广州plc编程员招聘 编辑:程序博客网 时间:2024/06/05 11:10
Description
The cows are having a merry little game with numbers. One of the cowspicks a positive integer N that is smaller than 32000. The cows thenplace bets on whether the length of the 'Collatz Sequence' will exceeda number like 100.The Collatz Sequence is calculated thusly. Start with an integer, C.* if C is 1, the sequence has endedOtherwise,* if C is even, then divide it by two to yield a new C* if C is odd, then replace it by 3*C+1 Continue the rules until the sequence ends.Consider the Collatz Sequence that starts with the integer 10:10, 5, 16, 8, 4, 2, 1It has length 7.Help one of the cows cheat. Given N, calculate the length of theCollatz Sequence.
Input
A single line with a single integer: N
Output
A single line with a single integer that is the length of the CollatzSequence starting with N
Sample Input
10
Sample Output
7
0 0
- The Collatz Code
- The Collatz Sequence
- uva694 The Collatz Sequence
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- UVa694 The Collatz Sequence
- The Collatz Sequence
- The Collatz Sequence
- The Collatz Sequence
- The Collatz Sequence
- 694 - The Collatz Sequence
- uva The Collatz Sequence
- 694 - The Collatz Sequence
- UVA694 - The Collatz Sequence
- 利用一般处理程序处理头像的浏览和更新
- gogent https模式 create ssl 连接 timed out
- boost ref()
- test4
- 如何为Eclipse安装主题(Color Theme)
- The Collatz Code
- How to Secure Apache Sqoop Jobs with Oracle Wallet
- python与复杂科学(2013-09-16 15:28:21)转载▼
- Vertical Histogram
- 2.5 Qt风格的编程规范
- 《天才在左 疯子在右》读书记
- 使用ThreadMXBean更精确地评估Thread占用时间
- 开源jQuery插件推荐,帮你快速构建单页网站
- Java实现视频网站的视频上传、视频转码、视频关键帧抽图, 及视频播放功能