**Exercise 2.5:** Show that we can represent pairs of nonnegative integers using only numbers and arithmetic operations if we represent the pair a and b as the integer that is the product 2^{a}3^{b}. Give the corresponding definitions of the procedures cons, car, and cdr.

The discrete log procedure is a cousin of **discrete-log** from 1.45.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
(define (cons a b) (* (expt 2 a) (expt 3 b))) (define (car x) (discrete-log x 2)) (define (cdr x) (discrete-log x 3)) (define (discrete-log n base) (if (not (= 0 (remainder n base))) 0 (+ 1 (discrete-log (/ n base) base)))) |