OFFSET
0,3
COMMENTS
If p is prime, a(p) = p.
A257173(n) = smallest number m such that a(m) = n. - Reinhard Zumkeller, Apr 17 2015
LINKS
Nathaniel Shar, Table of n, a(n) for n = 0..10000
EXAMPLE
a(9) = 6 because a(8) = 2, a(7) = 7, a(6) = 2, a(5) = 5, a(4) = 2 are all relatively prime to 9, but a(3) = 3 is not.
PROG
(PARI) findk(va, n) = {k = 1; while (gcd(va[n-k], n) == 1, k++; if (k==n, break)); k; }
lista(nn) = {va = vector(nn); va[1] = 1; print1(0, ", ", va[1], ", "); for (n=2, nn, va[n] = findk(va, n); print1(va[n], ", "); ); } \\ Michel Marcus, Oct 17 2014
(Haskell)
import Data.List (findIndex); import Data.Maybe (fromMaybe)
a248737 n = a248737_list !! n
a248737_list = 0 : f 1 [0] where
f x ys = y : f (x + 1) (y : ys) where
y = (+ 1) $ fromMaybe (x - 1) $ findIndex (\z -> gcd z x /= 1) ys
-- Reinhard Zumkeller, Apr 17 2015
CROSSREFS
KEYWORD
nonn
AUTHOR
Nathaniel Shar, Oct 13 2014
STATUS
approved