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.




 
#lang racket
 
(define (non-square n)
  (+ n (exact-floor (+ 1/2 (sqrt n)))))
 
(map non-square (range 1 23))
 
(define (square? n) (integer? (sqrt n)))
 
(for/or ([n (in-range 1 1000001)])
  (square? (non-square n)))
 