March 19, 2015
nullprogram.com/blog/2015/03/19/
(The author is currently open to employment opportunities in the United States.)
This article was discussed on Hacker News and on reddit.
Monday’s /r/dailyprogrammer challenge was to write a program to read a recurrence relation definition and, through interpretation, iterate it to some number of terms. It’s given an initial term ( u(0) ) and a sequence of operations, f , to apply to the previous term ( u(n + 1) = f(u(n)) ) to compute the next term. Since it’s an easy challenge, the operations are limited to addition, subtraction, multiplication, and division, with one operand each.
For example, the relation u(n + 1) = (u(n) + 2) * 3 - 5 would be input as +2 *3 -5 . If u(0) = 0 then,
u(1) = 1
u(2) = 4
u(3) = 13
u(4) = 40
... continue reading