login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A175867 a(0) = 2; a(n) = a(n - 1) * 2 + 1 if a(n - 1) is prime, or a(n - 1) / (smallest prime factor) if it is composite. 1
2, 5, 11, 23, 47, 95, 19, 39, 13, 27, 9, 3, 7, 15, 5, 11, 23, 47, 95, 19, 39, 13, 27, 9, 3, 7, 15, 5, 11, 23, 47, 95, 19, 39, 13, 27, 9, 3, 7, 15, 5, 11, 23, 47, 95, 19, 39, 13, 27, 9, 3, 7, 15, 5, 11, 23, 47, 95, 19, 39, 13, 27, 9, 3, 7, 15, 5, 11, 23, 47, 95, 19, 39, 13, 27, 9, 3, 7 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,1
COMMENTS
a(n) repeats itself after 14 iterations. Peak is a(5) = 95.
The function is similar in nature to Collatz's 3x+1 problem, except that it deals with primality instead of parity.
LINKS
Wikipedia, Divisor
Wikipedia, Prime number
EXAMPLE
a(0) = 2
a(1) = 2 * 2 + 1 = 5, because a(0) was prime.
a(2) = 5 * 2 + 1 = 11, because a(1) was prime.
...
a(6) = 95 / 5 = 19, because the smallest prime factor of a(5) was 5.
MATHEMATICA
NestList[If[PrimeQ[#], 2#+1, #/FactorInteger[#][[1, 1]]]&, 2, 80] (* or *) PadRight[{2}, 80, {15, 5, 11, 23, 47, 95, 19, 39, 13, 27, 9, 3, 7}] (* Harvey P. Dale, Jun 14 2020 *)
PROG
(Python)
import math
from sympy import isprime
a = [2]
while not a[ -1] in a[:-1]:
if isprime(a[ -1]):
a.append(a[ -1] * 2 + 1)
else:
for div in range(2, int(math.sqrt(a[ -1])) + 1):
if not a[ -1] % div:
a.append(a[ -1] // div)
break
print(a)
CROSSREFS
Sequence in context: A000100 A293339 A348855 * A083005 A133489 A060153
KEYWORD
easy,nonn
AUTHOR
Grant Garcia, Sep 30 2010
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 9 17:23 EDT 2024. Contains 374187 sequences. (Running on oeis4.)