OFFSET
2,1
COMMENTS
The function (n + lpf(n)) / 2 reduces the input according to its lowest prime factor if it is composite or simply returns the input if it is prime.
Sequence contains only prime numbers (and every prime number).
LINKS
Dumitru Damian, Table of n, a(n) for n = 2..30000
EXAMPLE
7 is prime, so (7 + lpf(7)) / 2 = (7 + 7) / 2 = 7.
15 is composite: (15 + 3) / 2 = 9, (9 + 3) / 2 = 6, (6 + 2) / 2 = 4, (4 + 2) / 2 = 3.
MATHEMATICA
g[n_] := (n + FactorInteger[n][[1, 1]])/2; f[n_] := Last@ NestWhileList[g, n, !PrimeQ@ # &]; Array[f, 73, 2]
PROG
(Python)
from sympy import factorint, isprime
def a177980(n):
while True:
if isprime(n): return n
else: n=int((n+A020639(n))/2)
[a177980(n) for n in range(2, 160)] # Dumitru Damian, Dec 15 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Grant Garcia, Dec 16 2010
STATUS
approved