# SICP Exercise 2.5

Great exercise! The procedure cons is defined as:

```
(define (cons a b)
(* (exp 2 a) (exp 3 b)))
```

Using exp procedure from earlier. And for car and cdr:

```
(define (car x)
(define (iter x count)
(if (= (remainder x 2) 0)
(iter (/ x 2) (+ count 1))
count))
(iter x 0))
(define (cdr x)
(define (iter x count)
(if (= (remainder x 3) 0)
(iter (/ x 3) (+ count 1))
count))
(iter x 0))
```

Simple explanation:

- car: everytime remainder of result and 2 is 0, increase count by 1
- cdr: everytime remainder of result and 3 is 0, increase count by 1