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.

Showing 1-10 of 12 results. Next

A302840 Lexicographically earliest sequence of distinct positive terms such that any n > 0, A065359(a(n)) <= A065368(a(n+1)).

Original entry on oeis.org

1, 2, 3, 4, 5, 10, 6, 8, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 21, 23, 26, 24, 25, 29, 38, 27, 28, 37, 41, 31, 45, 32, 35, 36, 40, 30, 44, 39, 46, 34, 42, 33, 47, 43, 48, 49, 50, 51, 52, 53, 74, 55, 65, 82, 73, 77, 83, 86, 90, 56, 59, 63, 64, 81
Offset: 1

Views

Author

Rémy Sigrist, Apr 14 2018

Keywords

Comments

See A302839 for a sequence with digital sums instead of alternate digital sums.

Examples

			The first terms, alongside their alternate digital sums in bases 2 and 3, are:
  n   a(n)  s2(a(n))  s3(a(n))
  --  ----  --------  --------
   1     1         1         1
   2     2        -1         2
   3     3         0        -1
   4     4         1         0
   5     5         2         1
   6    10        -2         2
   7     6         0        -2
   8     8        -1         0
   9     7         1        -1
  10     9         0         1
  11    11        -1         3
  12    12         0         0
  13    13         1         1
  14    14        -1         2
  15    15         0        -1
  16    16         1         0
  17    17         2         1
  18    18         0         2
  19    19         1         3
  20    20         2         4
		

Crossrefs

Programs

  • PARI
    \\ See Links section.

A302659 Lexicographically earliest sequence of distinct positive terms such that, for any n > 0, A065368(a(n) * a(n+1)) = 0.

Original entry on oeis.org

1, 4, 2, 6, 8, 3, 12, 7, 16, 5, 24, 9, 28, 10, 14, 18, 20, 11, 32, 15, 44, 13, 36, 17, 40, 19, 52, 21, 48, 22, 26, 30, 34, 38, 42, 46, 50, 56, 23, 60, 25, 64, 27, 68, 29, 72, 31, 76, 35, 80, 33, 84, 37, 88, 41, 96, 43, 92, 39, 100, 45, 112, 47, 116, 49, 104
Offset: 1

Views

Author

Rémy Sigrist, Apr 11 2018

Keywords

Comments

For any base b > 1:
- let s_b be the alternate sum of digits in base b,
- in particular s_2 = A065359, s_3 = A065368 and s_10 = A225693,
- we can build an analog of this sequence, say f_b, by considering s_b instead of A065368,
- f_b is well defined: for any k > 0, s_b(k * (1 + b^(2*i + 1))) = 0 whenever k < b^(2*i + 1), hence we can always extend the sequence,
- f_b is conjectured to be a permutation of the natural numbers,
- the scatterplot of f_b shows lines that seem related to the value of s_b(f_b) mod b+1.
See A302544 for a similar sequence.

Examples

			The first terms, alongside the ternary representation of a(n) * a(n+1), are:
  n  a(n)    tern(a(n) * a(n+1))
  -- ----    -------------------
   1    1        11
   2    4        22
   3    2       110
   4    6      1210
   5    8       220
   6    3      1100
   7   12     10010
   8    7     11011
   9   16      2222
  10    5     11110
  11   24     22000
  12    9    100100
		

Crossrefs

Programs

  • PARI
    See Links section.

A065359 Alternating bit sum for n: replace 2^k with (-1)^k in binary expansion of n.

Original entry on oeis.org

0, 1, -1, 0, 1, 2, 0, 1, -1, 0, -2, -1, 0, 1, -1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 0, 1, -1, 0, 1, 2, 0, 1, -1, 0, -2, -1, 0, 1, -1, 0, -2, -1, -3, -2, -1, 0, -2, -1, 0, 1, -1, 0, 1, 2, 0, 1, -1, 0, -2, -1, 0, 1, -1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 0, 1, -1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 1, 2, 0, 1, 2, 3, 1, 2, 0, 1, -1, 0, 1, 2, 0, 1, -1, 0, -2
Offset: 0

Views

Author

Marc LeBrun, Oct 31 2001

Keywords

Comments

Notation: (2)[n](-1)
From David W. Wilson and Ralf Stephan, Jan 09 2007: (Start)
a(n) is even iff n in A001969; a(n) is odd iff n in A000069.
a(n) == 0 (mod 3) iff n == 0 (mod 3).
a(n) == 0 (mod 6) iff (n == 0 (mod 3) and n/3 not in A036556).
a(n) == 3 (mod 6) iff (n == 0 (mod 3) and n/3 in A036556). (End)
a(n) = A030300(n) - A083905(n). - Ralf Stephan, Jul 12 2003
From Robert G. Wilson v, Feb 15 2011: (Start)
First occurrence of k and -k: 0, 1, 2, 5, 10, 21, 42, 85, ..., (A000975); i.e., first 0 occurs for 0, first 1 occurs for 1, first -1 occurs at 2, first 2 occurs for 5, etc.;
a(n)=-3 only if n mod 3 = 0,
a(n)=-2 only if n mod 3 = 1,
a(n)=-1 only if n mod 3 = 2,
a(n)= 0 only if n mod 3 = 0,
a(n)= 1 only if n mod 3 = 1,
a(n)= 2 only if n mod 3 = 2,
a(n)= 3 only if n mod 3 = 0, ..., . (End)
a(n) modulo 2 is the Prouhet-Thue-Morse sequence A010060. - Philippe Deléham, Oct 20 2011
In the Koch curve, number the segments starting with n=0 for the first segment. The net direction (i.e., the sum of the preceding turns) of segment n is a(n)*60 degrees. This is since in the curve each base-4 digit 0,1,2,3 of n is a sub-curve directed respectively 0, +60, -60, 0 degrees, which is the net 0,+1,-1,0 of two bits in the sum here. - Kevin Ryde, Jan 24 2020

Examples

			Alternating bit sum for 11 = 1011 in binary is 1 - 1 + 0 - 1 = -1, so a(11) = -1.
		

Crossrefs

Cf. A005536 (partial sums), A056832 (abs first differences), A010060 (mod 2), A039004 (indices of 0's).
Cf. also A004718.
Cf. analogous sequences for bases 3-10: A065368, A346688, A346689, A346690, A346691, A346731, A346732, A055017 and also A373605 (for primorial base).

Programs

  • Haskell
    a065359 0 = 0
    a065359 n = - a065359 n' + m where (n', m) = divMod n 2
    -- Reinhard Zumkeller, Mar 20 2015
    
  • Maple
    A065359 := proc(n) local dgs ; dgs := convert(n,base,2) ; add( -op(i,dgs)*(-1)^i,i=1..nops(dgs)) ; end proc: # R. J. Mathar, Feb 04 2011
  • Mathematica
    f[0]=0; f[n_] := Plus @@ (-(-1)^Range[ Floor[ Log2@ n + 1]] Reverse@ IntegerDigits[n, 2]); Array[ f, 107, 0]
  • PARI
    a(n) = my(s=0, u=1); for(k=0,#binary(n)-1,s+=bittest(n,k)*u;u=-u);s /* Washington Bomfim, Jan 18 2011 */
    
  • PARI
    a(n) = my(b=binary(n)); b*[(-1)^k|k<-[-#b+1..0]]~; \\ Ruud H.G. van Tol, Oct 16 2023
    
  • PARI
    a(n) = if(n==0, 0, 2*hammingweight(bitand(n, ((4<<(2*logint(n,4)))-1)/3)) - hammingweight(n)) \\ Andrew Howroyd, Dec 14 2024
    
  • Python
    def a(n):
        return sum((-1)**k for k, bi in enumerate(bin(n)[2:][::-1]) if bi=='1')
    print([a(n) for n in range(107)]) # Michael S. Branicky, Jul 13 2021
    
  • Python
    from sympy.ntheory import digits
    def A065359(n): return sum((0,1,-1,0)[i] for i in digits(n,4)[1:]) # Chai Wah Wu, Jul 19 2024

Formula

G.f.: (1/(1-x)) * Sum_{k>=0} (-1)^k*x^2^k/(1+x^2^k). - Ralf Stephan, Mar 07 2003
a(0) = 0, a(2n) = -a(n), a(2n+1) = 1-a(n). - Ralf Stephan, Mar 07 2003
a(n) = Sum_{k>=0} A030308(n,k)*(-1)^k. - Philippe Deléham, Oct 20 2011
a(n) = -a(floor(n/2)) + n mod 2. - Reinhard Zumkeller, Mar 20 2015
a(n) = A139351(n) - A139352(n). - Kevin Ryde, Jan 24 2020
G.f. A(x) satisfies: A(x) = x / (1 - x^2) - (1 + x) * A(x^2). - Ilya Gutkovskiy, Jul 28 2021
a(n) = A195017(A019565(n)). - Antti Karttunen, Jun 19 2024

Extensions

More terms from Ralf Stephan, Jul 12 2003

A055017 Difference between sums of alternate digits of n starting with the last, i.e., (sum of ultimate digit of n, antepenultimate digit of n, ...) - (sum of penultimate digit of n, preantepenultimate digit of n, ...).

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, -8, -7, -6, -5, -4, -3
Offset: 0

Views

Author

Henry Bottomley, May 31 2000

Keywords

Comments

a(n) is a multiple of 11 iff n is divisible by 11.
Digital sum with alternating signs starting with a positive sign for the rightmost digit. - Hieronymus Fischer, Jun 18 2007
For n < 100, a(n) = (n mod 10 - floor(n/10)) = -A076313(n). - Hieronymus Fischer, Jun 18 2007

Examples

			a(123) = 3-2+1 = 2, a(9875) = 5-7+8-9 = -3.
		

Crossrefs

Cf. A225693 (alternating sum of digits).
Unsigned version differs from A040114 and A040115 when n=100 and from A040997 when n=101.
Cf. A004086.
Cf. analogous sequences for bases 2-9: A065359, A065368, A346688, A346689, A346690, A346691, A346731, A346732 and also A373605 (for primorial base).

Programs

  • Maple
    sumodigs := proc(n) local dg; dg := convert(n,base,10) ; add(op(1+2*i,dg), i=0..floor(nops(dg)-1)/2) ; end proc:
    sumedigs := proc(n) local dg; dg := convert(n,base,10) ; add(op(2+2*i,dg), i=0..floor(nops(dg)-2)/2) ; end proc:
    A055017 := proc(n) sumodigs(n)-sumedigs(n) ; end proc: # R. J. Mathar, Aug 26 2011
  • Python
    def A055017(n): return sum((-1 if i % 2 else 1)*int(j) for i, j in enumerate(str(n)[::-1])) # Chai Wah Wu, May 11 2022
  • Smalltalk
    "Recursive version for general bases"
    "Set base = 10 for this sequence"
    altDigitalSumRight: base
    | s |
    base = 1 ifTrue: [^self \\ 2].
    (s := self // base) > 0
      ifTrue: [^(self - (s * base) - (s altDigitalSumRight: base))]
      ifFalse: [^self]
    [by Hieronymus Fischer, Mar 23 2014]
    

Formula

From Hieronymus Fischer, Jun 18 2007, Jun 25 2007, Mar 23 2014: (Start)
a(n) = n + 11*Sum_{k>=1} (-1)^k*floor(n/10^k).
a(10n+k) = k - a(n), 0 <= k < 10.
G.f.: Sum_{k>=1} (x^k-x^(k+10^k)+(-1)^k*11*x^(10^k))/((1-x^(10^k))*(1-x)).
a(n) = n + 11*Sum_{k=10..n} Sum_{j|k,j>=10} (-1)^floor(log_10(j))*(floor(log_10(j)) - floor(log_10(j-1))).
G.f. expressed in terms of Lambert series: g(x) = (x/(1-x)+11*L[b(k)](x))/(1-x) where L[b(k)](x) = Sum_{k>=0} b(k)*x^k/(1-x^k) is a Lambert series with b(k) = (-1)^floor(log_10(k)) if k>1 is a power of 10, otherwise b(k)=0.
G.f.: (1/(1-x)) * Sum_{k>=1} (1+11*c(k))*x^k, where c(k) = Sum_{j>=2,j|k} (-1)^floor(log_10(j))*(floor(log_10(j))-floor(log_10(j-1))).
Formulas for general bases b > 1 (b = 10 for this sequence).
a(n) = Sum_{k>=0} (-1)^k*(floor(n/b^k) mod b).
a(n) = n + (b+1)*Sum_{k>=1} (-1)^k*floor(n/b^k). Both sums are finite with floor(log_b(n)) as the highest index.
a(n) = a(n mod b^k) + (-1)^k*a(floor(n/b^k)), for all k >= 0.
a(n) = a(n mod b) - a(floor(n/b)).
a(n) = a(n mod b^2) + a(floor(n/b^2)).
a(n) = (-1)^m*A225693(n), where m = floor(log_b(n)).
a(n) = (-1)^k*A225693(A004086(n)), where k = is the number of trailing 0's of n, formally, k = max(j | n == 0 (mod 10^j)).
a(A004086(A004086(n))) = (-1)^k*a(n), where k = is the number of trailing 0's in the decimal representation of n. (End)

A346690 Replace 6^k with (-1)^k in base-6 expansion of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, -1, 0, 1, 2, 3, 4, -2, -1, 0, 1, 2, 3, -3, -2, -1, 0, 1, 2, -4, -3, -2, -1, 0, 1, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, -1, 0, 1, 2, 3, 4, -2, -1, 0, 1, 2, 3, -3, -2, -1, 0, 1, 2, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, -1, 0, 1, 2, 3, 4, -2, -1, 0, 1, 2, 3, -3, -2, -1
Offset: 0

Views

Author

Ilya Gutkovskiy, Jul 29 2021

Keywords

Comments

If n has base-6 expansion abc..xyz with least significant digit z, a(n) = z - y + x - w + ...

Examples

			59 = 135_6, 5 - 3 + 1 = 3, so a(59) = 3.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) option remember; (n mod 6) - procname(floor(n/6)) end proc:
    f(0):= 0:
    map(f, [$1..100]); # Robert Israel, Nov 21 2022
  • Mathematica
    nmax = 104; A[] = 0; Do[A[x] = x (1 + 2 x + 3 x^2 + 4 x^3 + 5 x^4)/(1 - x^6) - (1 + x + x^2 + x^3 + x^4 + x^5) A[x^6] + O[x]^(nmax + 1) // Normal, nmax + 1]; CoefficientList[A[x], x]
    Table[n + 7 Sum[(-1)^k Floor[n/6^k], {k, 1, Floor[Log[6, n]]}], {n, 0, 104}]
  • PARI
    a(n) = subst(Pol(digits(n, 6)), 'x, -1); \\ Michel Marcus, Nov 22 2022
  • Python
    from sympy.ntheory.digits import digits
    def a(n):
        return sum(bi*(-1)**k for k, bi in enumerate(digits(n, 6)[1:][::-1]))
    print([a(n) for n in range(105)]) # Michael S. Branicky, Jul 29 2021
    

Formula

G.f. A(x) satisfies: A(x) = x * (1 + 2*x + 3*x^2 + 4*x^3 + 5*x^4) / (1 - x^6) - (1 + x + x^2 + x^3 + x^4 + x^5) * A(x^6).
a(n) = n + 7 * Sum_{k>=1} (-1)^k * floor(n/6^k).
a(6*n+j) = j - a(n) for 0 <= j <= 5. - Robert Israel, Nov 21 2022

A373605 Sum of the even-indexed digits minus the sum of the odd-indexed digits in the primorial base representation (A049345) of n.

Original entry on oeis.org

0, 1, -1, 0, -2, -1, 1, 2, 0, 1, -1, 0, 2, 3, 1, 2, 0, 1, 3, 4, 2, 3, 1, 2, 4, 5, 3, 4, 2, 3, -1, 0, -2, -1, -3, -2, 0, 1, -1, 0, -2, -1, 1, 2, 0, 1, -1, 0, 2, 3, 1, 2, 0, 1, 3, 4, 2, 3, 1, 2, -2, -1, -3, -2, -4, -3, -1, 0, -2, -1, -3, -2, 0, 1, -1, 0, -2, -1, 1, 2, 0, 1, -1, 0, 2, 3, 1, 2, 0, 1, -3, -2, -4, -3, -5, -4, -2, -1, -3
Offset: 0

Views

Author

Antti Karttunen, Jun 18 2024

Keywords

Comments

Alternating digit sum in primorial base, starting with a positive sign for the rightmost (least significant) digit.

Examples

			A049345(85) = 2401, thus the sum of digits at even positions (with the rightmost digit having index 0) is 1+4 = 5, and at the odd positions 0+2 = 2, therefore a(85) = 5-2 = 3.
		

Crossrefs

Cf. A049345, A195017, A276086, A373606, A373607, A373830, A373831 (indices of multiples of 3).
Analogous sequences for bases 2-10: A065359, A065368, A346688, A346689, A346690, A346691, A346731, A346732, A055017.

Programs

  • PARI
    A373605(n) = { my(p=2, i=1, s=0); while(n, s += i*(n%p); n = n\p; p = nextprime(1+p); i = -i); (s); };

Formula

a(n) = A373606(n) - A373607(n).
a(n) = A195017(A276086(n)).

A346688 Replace 4^k with (-1)^k in base-4 expansion of n.

Original entry on oeis.org

0, 1, 2, 3, -1, 0, 1, 2, -2, -1, 0, 1, -3, -2, -1, 0, 1, 2, 3, 4, 0, 1, 2, 3, -1, 0, 1, 2, -2, -1, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3, -1, 0, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3, -1, 0, 1, 2, -2, -1, 0, 1, -3, -2, -1, 0, -4, -3, -2, -1, 0, 1, 2, 3, -1, 0, 1, 2, -2, -1, 0, 1, -3, -2, -1, 0, 1, 2, 3, 4, 0, 1, 2, 3, -1
Offset: 0

Views

Author

Ilya Gutkovskiy, Jul 29 2021

Keywords

Comments

If n has base-4 expansion abc..xyz with least significant digit z, a(n) = z - y + x - w + ...

Examples

			54 = 312_4, 2 - 1 + 3 = 4, so a(54) = 4.
		

Crossrefs

Programs

  • Mathematica
    nmax = 104; A[] = 0; Do[A[x] = x (1 + 2 x + 3 x^2)/(1 - x^4) - (1 + x + x^2 + x^3) A[x^4] + O[x]^(nmax + 1) // Normal, nmax + 1]; CoefficientList[A[x], x]
    Table[n + 5 Sum[(-1)^k Floor[n/4^k], {k, 1, Floor[Log[4, n]]}], {n, 0, 104}]
  • Python
    from sympy.ntheory.digits import digits
    def a(n):
        return sum(bi*(-1)**k for k, bi in enumerate(digits(n, 4)[1:][::-1]))
    print([a(n) for n in range(105)]) # Michael S. Branicky, Jul 29 2021

Formula

G.f. A(x) satisfies: A(x) = x * (1 + 2*x + 3*x^2) / (1 - x^4) - (1 + x + x^2 + x^3) * A(x^4).
a(n) = n + 5 * Sum_{k>=1} (-1)^k * floor(n/4^k).

A346689 Replace 5^k with (-1)^k in base-5 expansion of n.

Original entry on oeis.org

0, 1, 2, 3, 4, -1, 0, 1, 2, 3, -2, -1, 0, 1, 2, -3, -2, -1, 0, 1, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, -1, 0, 1, 2, 3, -2, -1, 0, 1, 2, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, -1, 0, 1, 2, 3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8
Offset: 0

Views

Author

Ilya Gutkovskiy, Jul 29 2021

Keywords

Comments

If n has base-5 expansion abc..xyz with least significant digit z, a(n) = z - y + x - w + ...

Examples

			48 = 143_5, 3 - 4 + 1 = 0, so a(48) = 0.
		

Crossrefs

Programs

  • Mathematica
    nmax = 104; A[] = 0; Do[A[x] = x (1 + 2 x + 3 x^2 + 4 x^3)/(1 - x^5) - (1 + x + x^2 + x^3 + x^4) A[x^5] + O[x]^(nmax + 1) // Normal, nmax + 1]; CoefficientList[A[x], x]
    Table[n + 6 Sum[(-1)^k Floor[n/5^k], {k, 1, Floor[Log[5, n]]}], {n, 0, 104}]
  • Python
    from sympy.ntheory.digits import digits
    def a(n):
        return sum(bi*(-1)**k for k, bi in enumerate(digits(n, 5)[1:][::-1]))
    print([a(n) for n in range(105)]) # Michael S. Branicky, Jul 29 2021

Formula

G.f. A(x) satisfies: A(x) = x * (1 + 2*x + 3*x^2 + 4*x^3) / (1 - x^5) - (1 + x + x^2 + x^3 + x^4) * A(x^5).
a(n) = n + 6 * Sum_{k>=1} (-1)^k * floor(n/5^k).

A346691 Replace 7^k with (-1)^k in base-7 expansion of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, -1, 0, 1, 2, 3, 4, 5, -2, -1, 0, 1, 2, 3, 4, -3, -2, -1, 0, 1, 2, 3, -4, -3, -2, -1, 0, 1, 2, -5, -4, -3, -2, -1, 0, 1, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, -1, 0, 1, 2, 3, 4, 5, -2, -1, 0, 1, 2, 3, 4, -3, -2, -1, 0, 1, 2, 3, -4, -3, -2, -1, 0, 1, 2, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8
Offset: 0

Views

Author

Ilya Gutkovskiy, Jul 29 2021

Keywords

Comments

If n has base-7 expansion abc..xyz with least significant digit z, a(n) = z - y + x - w + ...

Examples

			83 = 146_7, 6 - 4 + 1 = 3, so a(83) = 3.
		

Crossrefs

Programs

  • Mathematica
    nmax = 104; A[] = 0; Do[A[x] = x (1 + 2 x + 3 x^2 + 4 x^3 + 5 x^4 + 6 x^5)/(1 - x^7) - (1 + x + x^2 + x^3 + x^4 + x^5 + x^6) A[x^7] + O[x]^(nmax + 1) // Normal, nmax + 1]; CoefficientList[A[x], x]
    Table[n + 8 Sum[(-1)^k Floor[n/7^k], {k, 1, Floor[Log[7, n]]}], {n, 0, 104}]
  • Python
    from sympy.ntheory.digits import digits
    def a(n):
        return sum(bi*(-1)**k for k, bi in enumerate(digits(n, 7)[1:][::-1]))
    print([a(n) for n in range(105)]) # Michael S. Branicky, Jul 29 2021

Formula

G.f. A(x) satisfies: A(x) = x * (1 + 2*x + 3*x^2 + 4*x^3 + 5*x^4 + 6*x^5) / (1 - x^7) - (1 + x + x^2 + x^3 + x^4 + x^5 + x^6) * A(x^7).
a(n) = n + 8 * Sum_{k>=1} (-1)^k * floor(n/7^k).

A065364 Alternating sum of balanced ternary digits in n. Replace 3^k with (-1)^k in balanced ternary expansion of n.

Original entry on oeis.org

1, -2, -1, 0, 1, 2, 3, 0, 1, 2, -1, 0, 1, -2, -1, 0, -3, -2, -1, -4, -3, -2, -1, 0, 1, -2, -1, 0, -3, -2, -1, 0, 1, 2, -1, 0, 1, -2, -1, 0, 1, 2, 3, 0, 1, 2, -1, 0, 1, 2, 3, 4, 1, 2, 3, 0, 1, 2, 3, 4, 5, 2, 3, 4, 1, 2, 3, 0, 1, 2, -1, 0, 1, -2, -1, 0, 1, 2, 3, 0, 1, 2, -1, 0, 1, 2, 3, 4, 1, 2, 3, 0, 1, 2, -1, 0, 1, -2, -1, 0, -3, -2, -1, 0
Offset: 1

Views

Author

Marc LeBrun, Oct 31 2001

Keywords

Comments

Notation: (3)(-1).

Examples

			5 = +1(9)-1(3)-1(1) -> +1(+1)-1(-1)-1(+1) = +1 = a(5).
		

Crossrefs

Programs

  • Mathematica
    Array[Total@ MapIndexed[#1 (2 Mod[First[#2], 2] - 1) &, Reverse@ #] &[Prepend[IntegerDigits[#, 3], 0] //. {a___, b_, 2, c___} :> {a, b + 1, -1, c}] &, 104] (* Michael De Vlieger, Jun 27 2020 *)
Showing 1-10 of 12 results. Next