Monthly Archives: February 2014

Solution to Problem 32 on ProjectEuler

The problem: We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 […]

Factorial Algorithm in Lisp/Scheme

Below you’ll find a recursive and an iterative version of the Factorial algorithm in Lisp/Scheme, based on the book Structure and Interpretation of Computer Programs (SICP). Recursive (define (factorial n)         (if (= n 1)                 1                 (* n (factorial (- n 1) ))         )) (display (factorial 7)) Iterative (define (factorial n)         (define (iter product counter)                 (if […]