Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,8 @@
|
|||
def hailstone = { long start ->
|
||||
def sequence = []
|
||||
while (start != 1) {
|
||||
sequence << start
|
||||
start = (start % 2l == 0l) ? start / 2l : 3l * start + 1l
|
||||
}
|
||||
sequence << start
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
def sequence = hailstone(27)
|
||||
assert sequence.size() == 112
|
||||
assert sequence[0..3] == [27, 82, 41, 124]
|
||||
assert sequence[-4..-1] == [8, 4, 2, 1]
|
||||
|
||||
def results = (1..100000).collect { [n:it, size:hailstone(it).size()] }.max { it.size }
|
||||
println results
|
||||
Loading…
Add table
Add a link
Reference in a new issue