Data update

This commit is contained in:
Ingy döt Net 2025-08-11 18:05:26 -07:00
parent 4d5544505c
commit 4924dd0264
3073 changed files with 55820 additions and 4408 deletions

View file

@ -0,0 +1,27 @@
# Generate the hailstone sequence without an index
create or replace function hailstone(start) as table (
with recursive cte as (
select start as n
union all
select if( n % 2 = 0, n // 2, 3 * n + 1) as n
from cte
where n != 1
) from cte
);
# The length of the hailstone sequence of nn using count()
create or replace function hailstone_length(nn) as (
select count() as n from hailstone(nn)
);
# Return a tuple giving the seed and the hailstone sequence length
create or replace function hailstone_max_of_lengths(mx) as (
select max_by( (n,hailstone_length(n)), hailstone_length(n))
from range(1,mx+1) _(n)
);
# Table of lengths (e.g. for use with histogram())
create or replace function hailstone_lengths(mx) as table (
select hailstone_length(n) as length
from range(1,mx+1) _(n)
);