cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A048986 Home primes in base 2: primes reached when you start with n and (working in base 2) concatenate its prime factors (A048985); repeat until a prime is reached (or -1 if no prime is ever reached). Answer is written in base 10.

This page as a plain text file.
%I A048986 #28 Nov 13 2024 13:25:56
%S A048986 1,2,3,31,5,11,7,179,29,31,11,43,13,23,29,12007,17,47,19,251,31,43,23,
%T A048986 499,4091,4091,127,4091,29,127,31,1564237,59,4079,47,367,37,83,61,383,
%U A048986 41,179,43,499,4091,4091,47,683,127,173,113,173,53,191,4091
%N A048986 Home primes in base 2: primes reached when you start with n and (working in base 2) concatenate its prime factors (A048985); repeat until a prime is reached (or -1 if no prime is ever reached). Answer is written in base 10.
%C A048986 a(1) = 1 by convention.
%C A048986 The first binary home prime that is not known is a(2295). - _Ely Golden_, Jan 09 2017
%H A048986 Ely Golden, <a href="/A048986/b048986.txt">Table of n, a(n) for n = 1..2294</a>
%H A048986 Patrick De Geest, <a href="http://www.worldofnumbers.com/topic1.htm">Home Primes</a>
%H A048986 Ely Golden, <a href="http://www.mersennewiki.org/index.php/Base_2_Home_Prime_Results">Mersenne Wiki Home Primes base 2</a>
%H A048986 Ely Golden, <a href="/A048986/a048986_2.txt">Table of n, a(n) for n = 1..3000 (a-file)</a>
%e A048986 4 = 2*2 -> 1010 = 10 = 2*5 ->10101 = 21 = 3*7 -> 11111 = 31 = prime.
%t A048986 f[n_] := Module[{fi}, If[PrimeQ[n], n, fi = FactorInteger[n]; Table[ First[#], {Last[#]}]& /@ fi // Flatten // IntegerDigits[#, 2]& // Flatten // FromDigits[#, 2]&]]; a[1] = 1; a[n_] := TimeConstrained[FixedPoint[f, n], 1] /. $Aborted -> -1; Array[a, 55] (* _Jean-François Alcover_, Jan 01 2016 *)
%o A048986 (SageMath)
%o A048986 def digitLen(x,n):
%o A048986     r=0
%o A048986     while(x>0):
%o A048986         x//=n
%o A048986         r+=1
%o A048986     return r
%o A048986 def concatPf(x,n):
%o A048986     r=0
%o A048986     f=list(factor(x))
%o A048986     for c in range(len(f)):
%o A048986         for d in range(f[c][1]):
%o A048986             r*=(n**digitLen(f[c][0],n))
%o A048986             r+=f[c][0]
%o A048986     return r
%o A048986 def hp(x,n):
%o A048986     x1=concatPf(x,n)
%o A048986     while(x1!=x):
%o A048986         x=x1
%o A048986         x1=concatPf(x1,n)
%o A048986     return x
%o A048986 radix=2
%o A048986 index=2
%o A048986 while(index<=1344):
%o A048986     print(str(index)+" "+str(hp(index,radix)))
%o A048986     index+=1
%o A048986 (Python)
%o A048986 from sympy import factorint, isprime
%o A048986 def f(n):
%o A048986     if n == 1: return 1
%o A048986     return int("".join(bin(p)[2:]*e for p, e in factorint(n).items()), 2)
%o A048986 def a(n):
%o A048986     if n == 1: return 1
%o A048986     while not isprime(n): n = f(n)
%o A048986     return n
%o A048986 print([a(n) for n in range(1, 56)]) # _Michael S. Branicky_, Oct 07 2022
%Y A048986 Cf. A048985, A037274, A049065.
%K A048986 nonn,base,nice
%O A048986 1,2
%A A048986 Michael B Greenwald (mbgreen(AT)central.cis.upenn.edu)