Every odd integer is the difference of 2 squares

Started by cameyo, September 05, 2019, 06:34:11 AM

Previous topic - Next topic

cameyo

Try this:
(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.