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.




 
for i = 1 to 22
    print nonsqr( i); " ";
next i
print
 
found = 0
for i = 1 to 1000000
     j = ( nonsqr( i))^0.5
     if j = int( j) then
        found = 1
        print "Found square: "; i
        exit for
     end if
next i
if found =0 then print "No squares found"
 
end
 
function nonsqr( n)
    nonsqr = n +int( 0.5 +n^0.5)
end function
 