文件名称:create-function
介绍说明--下载内容均来自于网络,请自行研究使用
所谓的3x+1猜想就是:任取一个自然数,如果它是偶数,我们就把它除以2,如果它是奇数,我们就把它乘3再加上1。在这样一个变换下,我们就得到了一个新的自然数。如果反复使用这个变换,我们就会得到一串自然数,猜想就是:反复进行上述运算后,最后结果为1。
比如说我们先取5,首先我们得到3*5+1=16,然后是16/2=8,接下去是4,2和1,由1我们又得到4,于是我们就陷在4→2→1这个循环中了。
再举个例子,最开始的数取7,我们得到下面的序列:
7→22→11→34→17→52→26→13→40→20→10→5→16→8→4→2→1
请尝试用SQL给出这个问题的解决方案,可以以函数的形式提供,它接收一个数,返回到达1的序列。-The so-called 3x+1 guess is this: either take a natural number, if it is even, we' ll divide it by two, and if it is odd, we put it by 3 plus 1. In such a transformation, we get a new natural number. If you repeatedly use this transformation, we get a bunch of natural numbers, guess is this: After repeating the above operation, the final result is 1. For example, let' s take five, first we get 3* 5+1 = 16, then 16/2 = 8, and the latter is 4,2 and 1 by 1 we get four, so we stuck in 4 → 2 → 1 This cycle of. As another example, the start number is taken 7, we obtain the following sequence: 7 → 22 → 11 → 34 → 17 → 52 → 26 → 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1, please try to use SQL gives the solution to this problem can be provided in the form of a function, it receives a number, returns a sequence of reach.
比如说我们先取5,首先我们得到3*5+1=16,然后是16/2=8,接下去是4,2和1,由1我们又得到4,于是我们就陷在4→2→1这个循环中了。
再举个例子,最开始的数取7,我们得到下面的序列:
7→22→11→34→17→52→26→13→40→20→10→5→16→8→4→2→1
请尝试用SQL给出这个问题的解决方案,可以以函数的形式提供,它接收一个数,返回到达1的序列。-The so-called 3x+1 guess is this: either take a natural number, if it is even, we' ll divide it by two, and if it is odd, we put it by 3 plus 1. In such a transformation, we get a new natural number. If you repeatedly use this transformation, we get a bunch of natural numbers, guess is this: After repeating the above operation, the final result is 1. For example, let' s take five, first we get 3* 5+1 = 16, then 16/2 = 8, and the latter is 4,2 and 1 by 1 we get four, so we stuck in 4 → 2 → 1 This cycle of. As another example, the start number is taken 7, we obtain the following sequence: 7 → 22 → 11 → 34 → 17 → 52 → 26 → 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1, please try to use SQL gives the solution to this problem can be provided in the form of a function, it receives a number, returns a sequence of reach.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
create function.doc