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.




F non_square(Int n)
   R n + Int(floor(1/2 + sqrt(n)))
 
print_elements((1..22).map(non_square))
 
F is_square(n)
   R fract(sqrt(n)) == 0
 
L(i) 1 .< 10 ^ 6
   I is_square(non_square(i))
      print(‘Square found ’i)
      L.break
L.was_no_break
   print(‘No squares found’)