Every odd integer is the difference of 2 squares

Q&A's, tips, howto's
Post Reply
cameyo
Posts: 106
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy

Every odd integer is the difference of 2 squares

Post 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.

Post Reply