Task

Show that the following remarkable formula gives the sequence of non-square natural numbers:

            n + floor(1/2 + sqrt(n)) 

 Print out the values for    n    in the range   1   to   22
 Show that no squares occur for    n    less than one million


This is sequence   A000037   in the OEIS database.




#import nat
#import flo
 
nth_non_square = float; plus^/~& math..trunc+ plus/0.5+ sqrt
is_square      = sqrt; ^E/~& math..trunc
 
#show+
 
examples = %neALP ^(~&,nth_non_square)*t iota23
check    = (is_square*~+nth_non_square*t; ~&i&& %eLP)||-[no squares found]-! iota 1000000