r***c 发帖数: 95 | 1 在glassdoor上看到这个面试题,但是我不明白题目是什么意思。
貌似大家能看懂,而且提供了code solution。
不想看code,希望大侠能够帮忙解释一下题目含义。谢谢!
If the input is 6, then output should be the series 6 3 10 5 16 8 4 2 1,
similarly if input is 10 then it should be 10 5 16 8 4 2 1, and if input is
4 then output is 4 2 1. |
s******7 发帖数: 1758 | 2 如果是偶数,除二,如果是奇数,前两个相加再加1,直到最后等于1 |
h****3 发帖数: 89 | |
l******s 发帖数: 3045 | 4 补上前面的2*input?
【在 h****3 的大作中提到】 : 如果第一个数(input)就是奇数怎么办?
|
A*******e 发帖数: 2419 | 5 不想看code
why not?
,
is
【在 r***c 的大作中提到】 : 在glassdoor上看到这个面试题,但是我不明白题目是什么意思。 : 貌似大家能看懂,而且提供了code solution。 : 不想看code,希望大侠能够帮忙解释一下题目含义。谢谢! : If the input is 6, then output should be the series 6 3 10 5 16 8 4 2 1, : similarly if input is 10 then it should be 10 5 16 8 4 2 1, and if input is : 4 then output is 4 2 1.
|
b***e 发帖数: 1419 | 6 不想看code想看英文么?
https://en.wikipedia.org/wiki/Collatz_conjecture
这时一个著名的停机问题猜想。跟哥德巴赫猜想性质类似。
,
is
【在 r***c 的大作中提到】 : 在glassdoor上看到这个面试题,但是我不明白题目是什么意思。 : 貌似大家能看懂,而且提供了code solution。 : 不想看code,希望大侠能够帮忙解释一下题目含义。谢谢! : If the input is 6, then output should be the series 6 3 10 5 16 8 4 2 1, : similarly if input is 10 then it should be 10 5 16 8 4 2 1, and if input is : 4 then output is 4 2 1.
|
l*********u 发帖数: 19053 | 7 "前两个相加再加1",前面的=0
【在 h****3 的大作中提到】 : 如果第一个数(input)就是奇数怎么办?
|
r***c 发帖数: 95 | 8 谢谢!
【在 s******7 的大作中提到】 : 如果是偶数,除二,如果是奇数,前两个相加再加1,直到最后等于1
|
r***c 发帖数: 95 | 9 谢谢回复。
If n is even, divide it by 2 to get n / 2.
If n is odd, multiply it by 3 and add 1 to obtain 3n + 1.
Repeat the process (which has been called "Half Or Triple Plus One", or
HOTPO[6]) indefinitely.
The conjecture is that no matter what number you start with, you will always
eventually reach 1.
这个和二楼说的情形,一样么?
嗯,想自己写,所以不想看别人的code,嘿嘿。
【在 b***e 的大作中提到】 : 不想看code想看英文么? : https://en.wikipedia.org/wiki/Collatz_conjecture : 这时一个著名的停机问题猜想。跟哥德巴赫猜想性质类似。 : : , : is
|