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-5 of 5 results.

A379015 a(n) is the reversed non-adjacent form (NAF) representation of n.

Original entry on oeis.org

0, 1, 1, -3, 1, 5, -3, -7, 1, 9, 5, -19, -3, 13, -7, -15, 1, 17, 9, -11, 5, 21, -19, -35, -3, 29, 13, -39, -7, 25, -15, -31, 1, 33, 17, -23, 9, 41, -11, -27, 5, 37, 21, -83, -19, 45, -35, -67, -3, 61, 29, -51, 13, 77, -39, -71, -7, 57, 25, -79, -15, 49, -31, -63
Offset: 0

Views

Author

Darío Clavijo, Dec 13 2024

Keywords

Comments

Fixed points exist when the non-adjacent form is palindromic.

Examples

			For n=7 a(7) = -7 because:
7 to NAF encoding read from least to most significant bit: [-1, 0, 0, 1]
Reversed: [1, 0, 0, -1]
NAF to integer: -7.
		

Crossrefs

Programs

  • Mathematica
    a[n_]:=Module[{E=n,r=0},While[E>0,If[OddQ[E],Module[{Zi=2-Mod[E,4]},E-=Zi;r+=Zi;]];E=Floor[E/2];r*=2;];Floor[r/2]];Table[a[n],{n,0,63}] (* James C. McMahon, Dec 26 2024 *)
  • PARI
    a(n) = { my (r = 0, d); while (n, if (n%2, d = 2 - (n % 4); r += d; n -= d;); r *= 2; n \= 2;); return (r \ 2); } \\ Rémy Sigrist, Dec 28 2024
  • Python
    def a(n):
        E, r = n, 0
        while E:
            if E & 1:
                Zi = 2 - (E & 3)
                E -= Zi
                r += Zi
            E >>= 1
            r <<= 1
        return r >> 1
    print([a(n) for n in range(0,64)])
    

Formula

a(2^k) = 1.
a(A091072(n)) > 0 iff a(n) is in A016813.
a(A091067(n)) < 0 iff abs(a(n)) is in A004767.

Extensions

a(0) = 0 prepended by Rémy Sigrist, Dec 28 2024

A379657 The nonadjacent form of a(n) is obtained by inserting a digit 0 before each nonzero digit in the balanced ternary expansion of n.

Original entry on oeis.org

0, 1, 3, 2, 5, 11, 6, 13, 7, 4, 9, 19, 10, 21, 43, 22, 45, 23, 12, 25, 51, 26, 53, 27, 14, 29, 15, 8, 17, 35, 18, 37, 75, 38, 77, 39, 20, 41, 83, 42, 85, 171, 86, 173, 87, 44, 89, 179, 90, 181, 91, 46, 93, 47, 24, 49, 99, 50, 101, 203, 102, 205, 103, 52, 105
Offset: 0

Views

Author

Rémy Sigrist, Dec 29 2024

Keywords

Comments

A permutation of the nonnegative integers with inverse A379658.

Examples

			The first terms are:  n   a(n)  bter(n)  naf(a(n))
  --  ----  -------  ---------
   0     0        0          0
   1     1        1          1
   2     3       1T        10T
   3     2       10         10
   4     5       11        101
   5    11      1TT      10T0T
   6     6      1T0       10T0
   7    13      1T1      10T01
   8     7      10T       100T
   9     4      100        100
  10     9      101       1001
  11    19      11T      1010T
  12    10      110       1010
		

Crossrefs

See A048680 for a similar sequence.
Cf. A065363, A334913, A379658 (inverse).

Programs

  • PARI
    a(n) = { my (v = 0, d, b = 1); while (n, d = centerlift(Mod(n, 3)); n = (n-d)/3;
     v += d * b; b *= if (d, 4, 2);); v; }

Formula

A334913(a(n)) = A065363(n).

A379658 The balanced ternary expansion of a(n) is obtained by removing a digit 0 before each nonzero digit in the nonadjacent form of n.

Original entry on oeis.org

0, 1, 3, 2, 9, 4, 6, 8, 27, 10, 12, 5, 18, 7, 24, 26, 81, 28, 30, 11, 36, 13, 15, 17, 54, 19, 21, 23, 72, 25, 78, 80, 243, 82, 84, 29, 90, 31, 33, 35, 108, 37, 39, 14, 45, 16, 51, 53, 162, 55, 57, 20, 63, 22, 69, 71, 216, 73, 75, 77, 234, 79, 240, 242, 729
Offset: 0

Views

Author

Rémy Sigrist, Dec 29 2024

Keywords

Comments

A permutation of the nonnegative integers with inverse A379657.

Examples

			The first terms are:
  n   a(n)  naf(n)  bter(a(n))
  --  ----  ------  ----------
   0     0       0           0
   1     1       1           1
   2     3      10          10
   3     2     10T          1T
   4     9     100         100
   5     4     101          11
   6     6    10T0         1T0
   7     8    100T         10T
   8    27    1000        1000
   9    10    1001         101
  10    12    1010         110
  11     5   10T0T         1TT
  12    18   10T00        1T00
		

Crossrefs

See A048679 for a similar sequence.
Cf. A065363, A334913, A379657 (inverse).

Programs

  • PARI
    a(n) = { my (v = 0, t = 1, d); while (n, if (n%2, n -= d = 2 - (n%4); v += d*t; t /= 3;); n \= 2; t *= 3;); return (v); }

Formula

A065363(a(n)) = A334913(n).

A337123 a(n) is the number of primes p in the n-digit "signed nonadjacent form" such that p has 3 or fewer nonzero digits.

Original entry on oeis.org

0, 1, 2, 1, 4, 5, 7, 5, 9, 8, 12, 7, 11, 7, 11, 9, 14, 10, 18, 11, 21, 7, 9, 11, 16, 4, 8, 9, 7, 12, 18, 13, 14, 11, 10, 9, 18, 7, 12, 10, 18, 12, 22, 5, 11, 13, 16, 13, 22, 8, 9, 16, 13, 9, 13, 14, 10, 11, 10, 10, 20, 15, 9, 10, 13, 8, 22, 10, 10, 10, 12, 13
Offset: 1

Views

Author

Lei Zhou, Aug 17 2020

Keywords

Comments

Sign nonadjacent form notation is defined by the publications listed in the reference.
We use abbreviation SNF for "signed nonadjacent form" notation.
This is an expansion of A337124 to include 2 and primes in the form of 2^k+1 and 2^k-1.

Examples

			There is only one number in single-digit SNF notation, which is 1 and 1 is not a prime.  So a(1)=0;
There is only one number in the two-digit SNF notation, which is 10 = 2 base 10 and it is a prime with one nonzero digit.  So a(2)=1;
There are three numbers in three digits SNF notation: 10T = 3 base 10, 100 = 4 base 10, and 101 = 5 base 10.  There are two prime numbers among 3, 4, and 5 and both of them have two nonzero digits. So a(3)=2;
...
For seven-digit SNF numbers, 10T0T0T = 43 base 10 has 4 nonzero digits (excluded); 10T000T = 47 base 10 has 3 nonzero digits (included). Thereafter 10T0101 = 53: 4 digits, excluded; 1000T0T = 59: 3 digits, included; 1000T01 = 61: 3 digits, included; 100010T = 67: 3 digits, included; 100100T = 71: 3 digits, included; 1001001 = 73, 3 digits, included; 101000T = 79: 3 digits, included; 101010T = 83, 4 digits, excluded.  In total, 7 numbers fit the definition.  So a(7)=7.
		

References

  • Joerg Arndt, Matters Computational - Ideas, Algorithms, Source Code, 2011, Springer, pp. 61-62.

Crossrefs

Programs

  • Mathematica
    Table[s1=2^(n-1);ct=0; If[n>1, If[PrimeQ[s1+1],ct++]; If[PrimeQ[s1-1],ct++]; If[n>=5, Do[s2=2^i; If[PrimeQ[s1+s2+1],ct++]; If[PrimeQ[s1+s2-1],ct++]; If[PrimeQ[s1-s2+1],ct++]; If[PrimeQ[s1-s2-1],ct++], {i,2,n-3}]]]; ct, {n,1,72}]

A337124 a(n) is the number of primes p in the n-digit "signed nonadjacent form" such that p has three nonzero digits.

Original entry on oeis.org

0, 0, 0, 0, 3, 4, 7, 4, 8, 8, 12, 7, 11, 6, 11, 9, 13, 9, 18, 10, 21, 7, 9, 11, 16, 4, 8, 9, 7, 12, 18, 12, 14, 11, 10, 9, 18, 7, 12, 10, 18, 12, 22, 5, 11, 13, 16, 13, 22, 8, 9, 16, 13, 9, 13, 14, 10, 11, 10, 10, 20, 14, 9, 10, 13, 8, 22, 10, 10, 10, 12, 13
Offset: 1

Views

Author

Lei Zhou, Aug 17 2020

Keywords

Comments

Sign nonadjacent form notation is defined by the publications listed in the reference.
We use abbreviation SNF for "signed nonadjacent form" notation.

Examples

			It needs at least 5 digits to have three or more nonzero digits in SNF notation.  So a(1)=a(2)=a(3)=a(4)=0.
In 5-digit SNF numbers, 10T0T = 11 base 10, 10T01 = 13, and 10101 = 19 are primes with three nonzero digits in SNF notation.  So a(5)=3.  Another prime with 5 SNF digits, 10001 = 17 has only 2 SNF digits, so is excluded.
		

References

  • Joerg Arndt, Matters Computational - Ideas, Algorithms, Source Code, 2011, Springer, pp. 61-62.

Crossrefs

Programs

  • Mathematica
    Table[s1=2^(n-1);ct=0; If[n>=5, Do[s2=2^i; If[PrimeQ[s1+s2+1],ct++]; If[PrimeQ[s1+s2-1],ct++]; If[PrimeQ[s1-s2+1],ct++]; If
    [PrimeQ[s1-s2-1],ct++], {i,2,n-3}]]; ct, {n,1,73}]
Showing 1-5 of 5 results.