diff options
Diffstat (limited to 'Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/collatz.se')
-rw-r--r-- | Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/collatz.se | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/collatz.se b/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/collatz.se new file mode 100644 index 000000000..148b47b59 --- /dev/null +++ b/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/collatz.se @@ -0,0 +1,11 @@ +x = msg.data[0] +steps = 0 + +while x > 1: + steps += 1 + if (x % 2) == 0: + x /= 2 + else: + x = 3 * x + 1 + +return(steps) |