Data Update
This commit is contained in:
parent
e50b5c3114
commit
633b36288a
206 changed files with 4762 additions and 965 deletions
|
|
@ -2,16 +2,16 @@ func hailstone(n) {
|
|||
gather {
|
||||
while (n > 1) {
|
||||
take(n)
|
||||
n = (n.is_even ? n/2 : (3*n + 1))
|
||||
n = (n.is_even ? (n/2) : (take(3*n + 1)/2))
|
||||
}
|
||||
take(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (__FILE__ == __MAIN__) { # true when not imported
|
||||
var seq = hailstone(27)
|
||||
say "hailstone(27) - #{seq.len} elements: #{seq.ft(0, 3)} [...] #{seq.ft(-4)}"
|
||||
|
||||
say "hailstone(27) - #{seq.len} elements: #{seq.first(4)} [...] #{seq.last(4)}"
|
||||
|
||||
var n = 0
|
||||
var max = 0
|
||||
100_000.times { |i|
|
||||
|
|
@ -21,6 +21,6 @@ if (__FILE__ == __MAIN__) { # true when not imported
|
|||
n = i
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
say "Longest sequence is for #{n}: #{max}"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue