Displaying 1-10 of 48 results found.
a(n) = Product_{d|n, d<n} A019565( A289814(d)); a product obtained from the 2-digits present in ternary expansions of proper divisors of n.
+20
13
1, 1, 1, 2, 1, 2, 1, 2, 1, 4, 1, 6, 1, 6, 2, 12, 1, 6, 1, 4, 3, 4, 1, 36, 2, 2, 1, 12, 1, 36, 1, 36, 2, 12, 6, 30, 1, 10, 1, 240, 1, 180, 1, 20, 6, 20, 1, 1620, 3, 60, 6, 60, 1, 30, 4, 72, 5, 4, 1, 360, 1, 2, 15, 72, 2, 180, 1, 36, 10, 144, 1, 2700, 1, 2, 90, 20, 6, 180, 1, 720, 1, 4, 1, 540, 12, 6, 2, 720, 1, 900, 3, 100, 1, 20, 10, 16200, 1, 60, 6
PROG
(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
A289814(n) = { my (d=digits(n, 3)); fromdigits(vector(#d, i, if (d[i]==2, 1, 0)), 2); } \\ From _Remy Sigrist_
0, 1, 1, 2, 3, 3, 2, 3, 3, 4, 5, 5, 6, 7, 7, 6, 7, 7, 4, 5, 5, 6, 7, 7, 6, 7, 7, 8, 9, 9, 10, 11, 11, 10, 11, 11, 12, 13, 13, 14, 15, 15, 14, 15, 15, 12, 13, 13, 14, 15, 15, 14, 15, 15, 8, 9, 9, 10, 11, 11, 10, 11, 11, 12, 13, 13, 14, 15, 15, 14, 15, 15, 12
COMMENTS
The ones in the binary representation of a(n) correspond to the nonzero digits in the ternary representation of n; for example: ternary(42) = 1120 and binary(a(42)) = 1110 (a(42) = 14).
Each number k >= 0 appears 2^ A000120(k) times.
FORMULA
a(0) = 0.
a(3*n) = 2*a(n).
a(3*n + 1) = 2*a(n) + 1.
a(3*n + 2) = 2*a(n) + 1.
EXAMPLE
The first values, alongside the ternary representation of n, and the binary representation of a(n), are:
n a(n) ternary(n) binary(a(n))
-- ---- ---------- ------------
0 0 0 0
1 1 1 1
2 1 2 1
3 2 10 10
4 3 11 11
5 3 12 11
6 2 20 10
7 3 21 11
8 3 22 11
9 4 100 100
10 5 101 101
11 5 102 101
12 6 110 110
13 7 111 111
14 7 112 111
15 6 120 110
16 7 121 111
17 7 122 111
18 4 200 100
19 5 201 101
20 5 202 101
21 6 210 110
22 7 211 111
23 7 212 111
24 6 220 110
25 7 221 111
26 7 222 111
MATHEMATICA
Table[FromDigits[Sign@ IntegerDigits[n, 3], 2], {n, 0, 100}] (* Indranil Ghosh, Aug 03 2017 *)
PROG
(PARI) a(n) = my (d=digits(n, 3)); fromdigits(vector(#d, i, sign(d[i])), 2)
(Python)
from sympy.ntheory.factor_ import digits
from sympy import sign
def a(n):
d=digits(n, 3)[1:]
return int(''.join(str(sign(i)) for i in d), 2)
Filter based on 2-digits of base-3 expansion: a(n) = A278222( A289814(n)).
+20
6
1, 1, 2, 1, 1, 2, 2, 2, 4, 1, 1, 2, 1, 1, 2, 2, 2, 4, 2, 2, 6, 2, 2, 6, 4, 4, 8, 1, 1, 2, 1, 1, 2, 2, 2, 4, 1, 1, 2, 1, 1, 2, 2, 2, 4, 2, 2, 6, 2, 2, 6, 4, 4, 8, 2, 2, 6, 2, 2, 6, 6, 6, 12, 2, 2, 6, 2, 2, 6, 6, 6, 12, 4, 4, 12, 4, 4, 12, 8, 8, 16, 1, 1, 2, 1, 1, 2, 2, 2, 4, 1, 1, 2, 1, 1, 2, 2, 2, 4, 2, 2, 6, 2, 2, 6, 4, 4, 8, 1, 1, 2, 1
a(n) = Product_{d| A000265(n)} A019565( A289814(d)); a product obtained from the 2-digits present in ternary expansions of the odd divisors of n.
+20
5
1, 1, 1, 1, 2, 1, 3, 1, 1, 2, 2, 1, 1, 3, 6, 1, 6, 1, 5, 2, 15, 2, 10, 1, 30, 1, 1, 3, 2, 6, 1, 1, 6, 6, 36, 1, 1, 5, 1, 2, 2, 15, 3, 2, 30, 10, 10, 1, 15, 30, 90, 1, 30, 1, 28, 3, 35, 2, 14, 6, 21, 1, 105, 1, 28, 6, 7, 6, 210, 36, 42, 1, 35, 1, 3150, 5, 420, 1, 105, 2, 1, 2, 2, 15, 12, 3, 6, 2, 6, 30, 3, 10, 1, 10
PROG
(PARI)
A019565(n) = { my(m=1, p=1); while(n>0, p = nextprime(1+p); if(n%2, m *= p); n >>= 1); (m); };
A289814(n) = { my(d=digits(n, 3)); fromdigits(vector(#d, i, if (d[i]==2, 1, 0)), 2); };
1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1
a(n) = Product_{d|n, d<n} A019565( A289814( A295882(d))); a product obtained from the -1's present in balanced ternary representation of the deficiencies of the proper divisors of n.
+20
4
1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 3, 2, 1, 1, 12, 1, 2, 6, 1, 1, 12, 1, 1, 12, 3, 1, 12, 1, 1, 2, 15, 3, 216, 1, 5, 2, 6, 1, 6, 1, 2, 36, 5, 1, 180, 3, 10, 30, 1, 1, 1080, 1, 3, 10, 1, 1, 3240, 1, 1, 36, 1, 1, 20, 1, 450, 10, 30, 1, 45360, 1, 1, 30, 75, 3, 10, 1, 60, 360, 1, 1, 540, 15, 105, 2, 2, 1, 3240, 3, 50, 2, 35, 5, 2520, 1, 630, 60, 90, 1, 900
PROG
(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
A289814(n) = { my (d=digits(n, 3)); from digits(vector(#d, i, if (d[i]==2, 1, 0)), 2); } \\ From Rémy Sigrist
(Scheme)
(define ( A296072 n) (let loop ((m 1) (props (proper-divisors n))) (cond ((null? props) m) (else (loop (* m ( A019565 ( A289814 ( A295882 (car props))))) (cdr props))))))
(define (proper-divisors n) (reverse (cdr (reverse (divisors n)))))
(define (divisors n) (let loop ((k n) (divs (list))) (cond ((zero? k) divs) ((zero? (modulo n k)) (loop (- k 1) (cons k divs))) (else (loop (- k 1) divs)))))
a(n) = Product_{d|n} A019565( A289814(d)); a product obtained from the 2-digits present in ternary expansions of the divisors of n.
+20
3
1, 2, 1, 2, 2, 6, 3, 12, 1, 4, 2, 6, 1, 12, 6, 36, 6, 30, 5, 40, 15, 20, 10, 540, 30, 60, 1, 12, 2, 36, 1, 72, 6, 36, 36, 30, 1, 20, 1, 240, 2, 540, 3, 120, 30, 100, 10, 8100, 15, 600, 90, 900, 30, 210, 28, 1008, 35, 28, 14, 7560, 21, 84, 105, 504, 28, 1260, 7, 504, 210, 3024, 42, 94500, 35, 140, 3150, 700, 420, 18900
PROG
(PARI)
A019565(n) = { my(m=1, p=1); while(n>0, p = nextprime(1+p); if(n%2, m *= p); n >>= 1); (m); };
A289814(n) = { my(d=digits(n, 3)); fromdigits(vector(#d, i, if (d[i]==2, 1, 0)), 2); };
Sum of digits of (n written in base 3).
+10
114
0, 1, 2, 1, 2, 3, 2, 3, 4, 1, 2, 3, 2, 3, 4, 3, 4, 5, 2, 3, 4, 3, 4, 5, 4, 5, 6, 1, 2, 3, 2, 3, 4, 3, 4, 5, 2, 3, 4, 3, 4, 5, 4, 5, 6, 3, 4, 5, 4, 5, 6, 5, 6, 7, 2, 3, 4, 3, 4, 5, 4, 5, 6, 3, 4, 5, 4, 5, 6, 5, 6, 7, 4, 5, 6, 5, 6, 7, 6, 7, 8, 1, 2, 3, 2, 3, 4, 3, 4, 5, 2, 3, 4, 3, 4, 5, 4, 5, 6, 3, 4, 5, 4, 5, 6
COMMENTS
Also the fixed point of the morphism 0->{0,1,2}, 1->{1,2,3}, 2->{2,3,4}, etc. - Robert G. Wilson v, Jul 27 2006
LINKS
Jeffrey O. Shallit, Problem 6450, Advanced Problems, The American Mathematical Monthly, Vol. 91, No. 1 (1984), pp. 59-60; Two series, solution to Problem 6450, ibid., Vol. 92, No. 7 (1985), pp. 513-514.
Eric Weisstein's World of Mathematics, Digit Sum.
FORMULA
a(0) = 0, a(3n) = a(n), a(3n + 1) = a(n) + 1, a(3n + 2) = a(n) + 2.
a(n) = n - 2*Sum_{k>0} floor(n/3^k) = n - 2* A054861(n). (End)
In general, the sum of digits of (n written in base b) has generating function (Sum_{k>=0} (Sum_{0 <= i < b} i*x^(i*b^k))/(Sum_{i=0..b-1} x^(i*b^k)))/(1-x). - Franklin T. Adams-Watters, Nov 03 2005
G.f. satisfies G(x) = (x+2*x^2)/(1-x^3) + (1+x+x^2)*G(x^3), and has a natural boundary at |x|=1. - Robert Israel, Jul 02 2015
a(0) = 0; a(n) = a(n - 3^floor(log_3(n))) + 1. - Ilya Gutkovskiy, Aug 23 2019
Sum_{n>=1} a(n)/(n*(n+1)) = 3*log(3)/2 (Shallit, 1984). - Amiram Eldar, Jun 03 2021
EXAMPLE
a(20) = 2 + 0 + 2 = 4 because 20 is written as 202 base 3.
This can be written as a triangle with row lengths A025192 (see the example in the entry A000120):
0,
1,2,
1,2,3,2,3,4,
1,2,3,2,3,4,3,4,5,2,3,4,3,4,5,4,5,6,
1,2,3,2,3,4,3,4,5,2,3,4,3,4,5,4,5,6,3,4,5,4,5,6,5,6,7,2,3,4,3,4,5,4,5,6,3,...
where the k-th row contains a(3^k+i) for 0<=i<2*3^k and converges to A173523 as k->infinity. (End) [Changed conjectures to statements in this entry. - Franklin T. Adams-Watters, Jul 02 2015]
G.f. = x + 2*x^2 + x^3 + 2*x^4 + 3*x^5 + 2*x^6 + 3*x^7 + 4*x^8 + x^9 + 2*x^10 + ...
MAPLE
seq(convert(convert(n, base, 3), `+`), n=0..100); # Robert Israel, Jul 02 2015
MATHEMATICA
Table[Plus @@ IntegerDigits[n, 3], {n, 0, 100}] (* or *)
Nest[Join[#, # + 1, # + 2] &, {0}, 6] (* Robert G. Wilson v, Jul 27 2006 and modified Jul 27 2014 *)
PROG
(PARI) {a(n) = if( n<1, 0, a(n\3) + n%3)}; /* Michael Somos, Mar 06 2004 */
(PARI) A053735(n)=sumdigits(n, 3) \\ Requires version >= 2.7. Use sum(i=1, #n=digits(n, 3), n[i]) in older versions. - M. F. Hasler, Mar 15 2016
(Haskell)
a053735 = sum . a030341_row
(Scheme) (define ( A053735 n) (let loop ((n n) (s 0)) (if (zero? n) s (let ((d (mod n 3))) (loop (/ (- n d) 3) (+ s d)))))) ;; For R6RS standard. Use modulo instead of mod in older Schemes like MIT/GNU Scheme. - Antti Karttunen, Jun 03 2017
(MATLAB) m=1; for u=0:104; sol(m)=sum(dec2base(u, 3)-'0'); m=m+1; end
CROSSREFS
Sum of digits of n written in bases 2-16: A000120, this sequence, A053737, A053824, A053827, A053828, A053829, A053830, A007953, A053831, A053832, A053833, A053834, A053835, A053836.
Related base-3 sequences: A006047, A230641, A230642, A230643, A230853, A230854, A230855, A230856, A230639, A230640, A010063 (trajectory of 1), A286585, A286632, A289813, A289814.
0, 2, 1, 6, 8, 7, 3, 5, 4, 18, 20, 19, 24, 26, 25, 21, 23, 22, 9, 11, 10, 15, 17, 16, 12, 14, 13, 54, 56, 55, 60, 62, 61, 57, 59, 58, 72, 74, 73, 78, 80, 79, 75, 77, 76, 63, 65, 64, 69, 71, 70, 66, 68, 67, 27, 29, 28, 33, 35, 34, 30, 32, 31, 45, 47, 46, 51
COMMENTS
Could also be described as "Write n in base 3, then replace each digit with its base-3 negative" as with A048647 for base 4. - Henry Bottomley, Apr 19 2000
a(a(n)) = n, a self-inverse permutation of the nonnegative integers. - Reinhard Zumkeller, Dec 19 2003
First 3^n terms of the sequence form a permutation s(n) of 0..3^n-1, n>=1; the number of inversions of s(n) is A016142(n-1). - Gheorghe Coserea, Apr 23 2018
FORMULA
Tersum m + n: write m and n in base 3 and add mod 3 with no carries, e.g., 5 + 8 = "21" + "22" = "10" = 1.
a(n) = Sum(3-d(i)-3*0^d(i): n=Sum(d(i)*3^d(i): 0<=d(i)<3)). - Reinhard Zumkeller, Dec 19 2003
a(3*n) = 3*a(n), a(3*n+1) = 3*a(n)+2, a(3*n+2) = 3*a(n)+1. - Robert Israel, May 09 2014
MAPLE
a:= proc(n) local t, r, i;
t, r:= n, 0;
for i from 0 while t>0 do
r:= r+3^i *irem(2*irem(t, 3, 't'), 3)
od; r
end:
MATHEMATICA
a[n_] := FromDigits[Mod[3-IntegerDigits[n, 3], 3], 3]; Table[a[n], {n, 0, 66}] (* Jean-François Alcover, Mar 03 2014 *)
PROG
(Haskell)
a004488 0 = 0
a004488 n = if d == 0 then 3 * a004488 n' else 3 * a004488 n' + 3 - d
where (n', d) = divMod n 3
(PARI) a(n) = my(b=3); fromdigits(apply(d->(b-d)%b, digits(n, b)), b);
(Python)
from sympy.ntheory.factor_ import digits
def a(n): return int("".join([str((3 - i)%3) for i in digits(n, 3)[1:]]), 3) # Indranil Ghosh, Jun 06 2017
CROSSREFS
Cf. A048647, A055115, A055116, A055120, A059249, A117966, A117967, A117968, A225901, A242399, A244042, A263273, A289813, A289814, A289815, A289816, A289831, A289838, A300222, A321464.
Balanced ternary enumeration (based on balanced ternary representation) of integers; write n in ternary and then replace 2's with (-1)'s.
+10
48
0, 1, -1, 3, 4, 2, -3, -2, -4, 9, 10, 8, 12, 13, 11, 6, 7, 5, -9, -8, -10, -6, -5, -7, -12, -11, -13, 27, 28, 26, 30, 31, 29, 24, 25, 23, 36, 37, 35, 39, 40, 38, 33, 34, 32, 18, 19, 17, 21, 22, 20, 15, 16, 14, -27, -26, -28, -24, -23, -25, -30, -29, -31, -18, -17, -19, -15, -14, -16, -21, -20, -22, -36
COMMENTS
As the graph demonstrates, there are large discontinuities in the sequence between terms 3^i-1 and 3^i, and between terms 2*3^i-1 and 2*3^i. - N. J. A. Sloane, Jul 03 2016
REFERENCES
D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, Vol. 2, pp. 173-175; 2nd. ed. pp. 190-193.
FORMULA
a(0) = 0, a(3n) = 3a(n), a(3n+1) = 3a(n)+1, a(3n+2) = 3a(n)-1.
G.f. satisfies A(x) = 3*A(x^3)*(1+x+x^2) + x/(1+x+x^2). - corrected by Robert Israel, Nov 17 2015
EXAMPLE
7 in base 3 is 21; changing the 2 to a (-1) gives (-1)*3+1 = -2, so a(7) = -2. I.e., the number of -2 according to the balanced ternary enumeration is 7, which can be obtained by replacing every -1 by 2 in the balanced ternary representation (or expansion) of -2, which is -1,1.
MAPLE
f:= proc(n) local L, i;
L:= subs(2=-1, convert(n, base, 3));
add(L[i]*3^(i-1), i=1..nops(L))
end proc:
map(f, [$0..100]);
# alternate:
N:= 100: # to get a(0) to a(N)
g:= 0:
for n from 1 to ceil(log[3](N+1)) do
g:= convert(series(3*subs(x=x^3, g)*(1+x+x^2)+x/(1+x+x^2), x, 3^n+1), polynom);
od:
# third Maple program:
a:= proc(n) option remember; `if`(n=0, 0,
3*a(iquo(n, 3, 'r'))+`if`(r=2, -1, r))
end:
MATHEMATICA
Map[FromDigits[#, 3] &, IntegerDigits[#, 3] /. 2 -> -1 & /@ Range@ 80] (* Michael De Vlieger, Nov 17 2015 *)
PROG
(MIT/GNU Scheme:) (define ( A117966 n) (let loop ((z 0) (i 0) (n n)) (if (zero? n) z (loop (+ z (* (expt 3 i) (if (= 2 (modulo n 3)) -1 (modulo n 3)))) (1+ i) (floor->exact (/ n 3)))))) -- Antti Karttunen, May 19 2008
(PARI) a(n) = subst(Pol(apply(x->if(x == 2, -1, x), digits(n, 3)), 'x), 'x, 3)
(Python)
def a(n):
if n==0: return 0
if n%3==0: return 3*a(n//3)
elif n%3==1: return 3*a((n - 1)//3) + 1
else: return 3*a((n - 2)//3) - 1
Search completed in 0.021 seconds
|