A285332 a(0) = 1, a(1) = 2, a(2n) = A019565(a(n)), a(2n+1) = A065642(a(n)).
1, 2, 3, 4, 6, 9, 5, 8, 15, 12, 14, 27, 10, 25, 7, 16, 210, 45, 35, 18, 105, 28, 462, 81, 21, 20, 154, 125, 30, 49, 11, 32, 10659, 420, 910, 75, 78, 175, 33, 24, 3094, 315, 385, 56, 780045, 924, 374, 243, 110, 63, 55, 40, 4389, 308, 170170, 625, 1155, 60, 286, 343, 42, 121, 13, 64, 54230826, 31977, 28405, 630, 1330665, 1820, 714
Offset: 0
Links
- Antti Karttunen, Table of n, a(n) for n = 0..703
- Michael De Vlieger, Diagram of the binary tree of a(n) showing 1 <= n <= 2^8.
- Antti Karttunen and David J. Seal, Discussion on SeqFan mailing list
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
Programs
-
Mathematica
Block[{a = {1, 2}}, Do[AppendTo[a, If[EvenQ[i], Times @@ Prime@ Flatten@ Position[#, 1] &@ Reverse@ IntegerDigits[a[[i/2 + 1]], 2], If[# == 1, 1, Function[{n, c}, SelectFirst[Range[n + 1, n^2], Times @@ FactorInteger[#][[All, 1]] == c &]] @@ {#, Times @@ FactorInteger[#][[All, 1]]}] &[a[[(i - 1)/2 + 1]] ] ]], {i, 2, 70}]; a] (* Michael De Vlieger, Mar 12 2021 *)
-
PARI
A019565(n) = {my(j,v); factorback(Mat(vector(if(n, #n=vecextract(binary(n), "-1..1")), j, [prime(j), n[j]])~))}; \\ This function from M. F. Hasler A007947(n) = factorback(factorint(n)[, 1]); \\ From Andrew Lelechenko, May 09 2014 A065642(n) = { my(r=A007947(n)); if(1==n,n,n = n+r; while(A007947(n) <> r, n = n+r); n); }; A285332(n) = { if(n<=1,n+1,if(!(n%2),A019565(A285332(n/2)),A065642(A285332((n-1)/2)))); }; for(n=0, 4095, write("b285332.txt", n, " ", A285332(n)));
-
Python
from operator import mul from sympy import prime, primefactors def a007947(n): return 1 if n<2 else reduce(mul, primefactors(n)) def a019565(n): return reduce(mul, (prime(i+1) for i, v in enumerate(bin(n)[:1:-1]) if v == '1')) if n > 0 else 1 # This function from Chai Wah Wu def a065642(n): if n==1: return 1 r=a007947(n) n = n + r while a007947(n)!=r: n+=r return n def a(n): if n<2: return n + 1 if n%2==0: return a019565(a(n//2)) else: return a065642(a((n - 1)//2)) print([a(n) for n in range(51)]) # Indranil Ghosh, Apr 18 2017
-
Scheme
;; With memoization-macro definec. (definec (A285332 n) (cond ((<= n 1) (+ n 1)) ((even? n) (A019565 (A285332 (/ n 2)))) (else (A065642 (A285332 (/ (- n 1) 2))))))
Comments