(Python)
from __future__ import division
from fractions import gcd
def A151413(n):
....if n <= 2:
........return n
....else:
........l1, l2, m, b = 2, 1, 1, {1, 2}
........for j in range(3, 10**9):
............i = m
............while True:
................if not i in b:
....................if i == n:
........................return j
....................l1, l2, m = i, l1, l1//gcd(l1, i)
....................b.add(i)
....................break
................i += m
........return "search limit reached." # Chai Wah Wu, Dec 09 2014
