#!/usr/bin/perl
use 5.016;
use warnings;
no warnings qw(recursion);

# Golomb sequence
# http://e...content-available-to-author-only...a.org/wiki/Golomb_sequence
# thanx: http://t...content-available-to-author-only...h.net/test/read.cgi/tech/1390525149/329-330

my @memo;
sub f { $memo[$_[0]] //= ($_[0] < 2) ? 1 : 1 + f($_[0] - f(f($_[0] - 1))) }

say f(1);
say f(10);
say f(100);
say f(1000);
