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.

Previous Showing 11-13 of 13 results.

A323782 Prime numbers such that the reverse of the balanced ternary representation is a prime or a negated prime.

Original entry on oeis.org

2, 5, 7, 11, 13, 17, 29, 31, 37, 43, 53, 59, 61, 71, 73, 83, 89, 101, 103, 137, 139, 149, 163, 173, 179, 181, 193, 199, 223, 233, 241, 263, 269, 277, 311, 313, 331, 347, 353, 367, 373, 379, 383, 389, 401, 421, 443, 449, 457, 467, 479, 487, 499, 509, 541
Offset: 1

Views

Author

Philippe Cochin, Jan 27 2019

Keywords

Comments

The "warp" operation is an inverse map connecting this sequence and A323783.

Examples

			29 is a term:
29 is +0+- in balanced ternary notation
+0+- reversed is -+0+
-+0+ is -17 in balanced ternary notation
the absolute value of -17 is 17.
17 is prime
Therefore 29 is "warped" to -17.
This operation is reversible: -17 "warps" to 29.
		

Crossrefs

Supersequence of A224502.
Corresponding primes and -primes are in sequence A323783.
Primes that don't "warp" to a prime numbers are in sequence A323784.

Programs

  • PARI
    d3(n) = if ((n%3)==2, n\3+1, n\3);
    m3(n) = if ((n%3)==2, -1, n % 3);
    t(n) = if (n==0, [0], if (abs(n) == 1, [n], concat(m3(n), t(d3(n)))));
    f(n) = subst(Pol(Vec(t(n))), x, 3);
    isok(n) = isprime(n) && isprime(abs(f(n))); \\ Michel Marcus, Jan 29 2019
    
  • PARI
    is(n) = {if(!isprime(n), return(0)); my(d = digits(n, 3)); forstep(i = #d, 2, -1, if(d[i] >= 2, d[i] -= 3; d[i-1]++)); if(d[1] >= 2, d[1]-=3; d = concat(1, d)); isprime(abs(fromdigits(Vecrev(d), 3)))} \\ David A. Corneth, Feb 14 2019
  • Python
    # See links.
    

A323784 Prime numbers such that the reverse of the balanced ternary representation is neither prime nor a negated prime.

Original entry on oeis.org

3, 19, 23, 41, 47, 67, 79, 97, 107, 109, 113, 127, 131, 151, 157, 167, 191, 197, 211, 227, 229, 239, 251, 257, 271, 281, 283, 293, 307, 317, 337, 349, 359, 397, 409, 419, 431, 433, 439, 461, 463, 491, 503, 521, 523, 557, 563, 571, 577, 587, 593, 617, 619, 631, 641, 647, 653, 659, 661, 673, 683, 701, 733, 743, 769, 787, 797
Offset: 1

Views

Author

Philippe Cochin, Jan 28 2019

Keywords

Examples

			79 is a term:
79 is +00-+ in balanced ternary notation
+00-+ reversed is +-00+
+-00+ is 55 in balanced ternary notation
55 prime factors are 5 and 11
Therefore 55 is not prime.
Therefore the prime number 79 "warps" to the nonprime number 55.
This operation is reversible: 55 "warps" to 79.
		

Crossrefs

Complement of A323782 among primes.

Programs

  • PARI
    d3(n) = if ((n%3)==2, n\3+1, n\3);
    m3(n) = if ((n%3)==2, -1, n % 3);
    t(n) = if (n==0, [0], if (abs(n) == 1, [n], concat(m3(n), t(d3(n)))));
    f(n) = subst(Pol(Vec(t(n))), x, 3);
    isok(n) = isprime(n) && !isprime(abs(f(n))); \\ Michel Marcus, Jan 29 2019
  • Python
    # See Github link.
    

A327252 Balanced reversed ternary: Write n as ternary, reverse the order of the digits, then replace all 2's with (-1)'s.

Original entry on oeis.org

0, 1, -1, 1, 4, -2, -1, 2, -4, 1, 10, -8, 4, 13, -5, -2, 7, -11, -1, 8, -10, 2, 11, -7, -4, 5, -13, 1, 28, -26, 10, 37, -17, -8, 19, -35, 4, 31, -23, 13, 40, -14, -5, 22, -32, -2, 25, -29, 7, 34, -20, -11, 16, -38, -1, 26, -28, 8, 35, -19, -10, 17, -37, 2, 29, -25, 11
Offset: 0

Views

Author

Elisabeth Zemack, Sep 15 2019

Keywords

Examples

			5 in base 3 is 12; reversing the ternary gives 21; replacing the 2 with (-1) gives (-1),1 which is -2 in decimal.
		

Crossrefs

Cf. A134028 (reversed balanced ternary, i.e. balancing the ternary, then reversing the ternary and transforming back into decimal), A117966 (balanced ternary enumeration).

Programs

  • Maple
    a:= proc(n) local m, r; m, r:= n, 0;
          while m>0 do m, r:= iquo(m, 3), 3*r+mods(m, 3) od; r
        end:
    seq(a(n), n=0..3^4-1);  # Alois P. Heinz, Sep 17 2019
  • Mathematica
    a[n_] := FromDigits[Reverse[IntegerDigits[n, 3]] /. {2 -> -1}, 3]; Array[a, 67, 0] (* Giovanni Resta, Sep 17 2019 *)
  • PARI
    a(n) = fromdigits(apply(d -> if (d==2, -1, d), Vecrev(digits(n,3))), 3) \\ Rémy Sigrist, Sep 15 2019
  • Python
    def a(n):
        ternary = []
        i = math.floor(math.log(n,3))
        while i >= 0:
            for j in range (2, -1, -1):
                if j*(3**i) <= n:
                    if (j==2): ternary.append(-1)
                    else: ternary.append(j)
                    n -= j*(3**i)
                    break
            i -=1
        for k in range (0, len(ternary)):
            n += ternary[k]*(3**k)
        return n
    
Previous Showing 11-13 of 13 results.