# Start at `start` create or replace function task(start) as table ( with recursive cte as ( select start::BIGINT as n union all select n // 2 as n from cte where n > 0 -- "while n > 0" ) from cte where n > 0 -- comment me out to include the last 0 ); from task(1024);