Page 1 of 1

Every odd integer is the difference of 2 squares

Posted: Thu Sep 05, 2019 1:34 pm
by cameyo
Try this:

Code: Select all

(define (breaknum n)
  (if (even? n) nil
    (list (* (- n (/ n 2)) (- n (/ n 2))) (* (/ n 2) (/ n 2)) )))

(breaknum 11)
;-> (36 25)

(breaknum 9527)
;-> (22695696 22686169)
Proof
1) Pick an odd number (5):
OOOOO

2)Bend it in half:
OOO
O
O

3) Fill the rest:
OOO
OXX
OXX

The odd number is the area difference of the big (9) and small (4) squares.