Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,26 @@
func hailstone(n) {
gather {
while (n > 1) {
take(n)
n = (n.is_even ? n/2 : (3*n + 1))
}
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)}"
 
var n = 0
var max = 0
100_000.times { |i|
var seq = hailstone(i)
if (seq.len > max) {
max = seq.len
n = i
}
}
 
say "Longest sequence is for #{n}: #{max}"
}