OFFSET
0,1
LINKS
Antti Karttunen, Table of n, a(n) for n = 0..16383
Eric Weisstein's World of Mathematics, Pairing Function
MATHEMATICA
f[n_, i_, x_] := Which[n == 0, x, EvenQ@ n, f[n/2, i + 1, x], True, f[(n - 1)/2, i, x Prime@ i]]; g[n_] := If[n == 1, 1, Times @@ MapIndexed[ Prime[First@ #2]^#1 &, Sort[FactorInteger[n][[All, -1]], Greater]]]; h[n_] := g@ f[BitXor[n, Floor[n/2]], 1, 1]; Map[(2 + (#1 + #2)^2 - #1 - 3 #2)/2 & @@ # & /@ # &, Table[{h[n], h[n + 1]}, {k, 12}, {n, k (k - 1)/2, k (k + 1)/2 - 1}]] // Flatten (* Michael De Vlieger, May 09 2017 *)
PROG
(PARI)
A003188(n) = bitxor(n, n>>1);
A005940(n) = { my(p=2, t=1); n--; until(!n\=2, if((n%2), (t*=p), p=nextprime(p+1))); t }; \\ Modified from code of M. F. Hasler
A046523(n) = { my(f=vecsort(factor(n)[, 2], , 4), p); prod(i=1, #f, (p=nextprime(p+1))^f[i]); }; \\ This function from Charles R Greathouse IV, Aug 17 2011
for(n=0, 16383, write("b286241.txt", n, " ", A286241(n)));
(Scheme) (define (A286241 n) (* (/ 1 2) (+ (expt (+ (A278219 n) (A278219 (+ 1 n))) 2) (- (A278219 n)) (- (* 3 (A278219 (+ 1 n)))) 2)))
(Python)
from sympy import prime, factorint
import math
def T(n, m): return ((n + m)**2 - n - 3*m + 2)/2
def A(n): return n - 2**int(math.floor(math.log(n, 2)))
def b(n): return n + 1 if n<2 else prime(1 + (len(bin(n)[2:]) - bin(n)[2:].count("1"))) * b(A(n))
def a005940(n): return b(n - 1)
def P(n):
f = factorint(n)
return sorted([f[i] for i in f])
def a046523(n):
x=1
while True:
if P(n) == P(x): return x
else: x+=1
def a003188(n): return n^int(n/2)
def a243353(n): return a005940(1 + a003188(n))
def a278219(n): return a046523(a243353(n))
def a(n): return T(a278219(n), a278219(n + 1)) # Indranil Ghosh, May 07 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, May 07 2017
STATUS
approved