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 N% = 1 TO 22
        S% = N% + SQR(N%) + 0.5
        PRINT S%
      NEXT
 
      PRINT '"Checking...."
      FOR N% = 1 TO 999999
        S% = N% + SQR(N%) + 0.5
        R% = SQR(S%)
        IF S%/R% = R% STOP
      NEXT
      PRINT "No squares occur for n < 1000000"