with x (n,i) as ( select 676 as n, 0 as i from dual union all select n - floor(sqrt(n)) as n , i + 1 as i from x where n >= 1 ) select count(*) from x