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

A079360 Sequence of sums of alternating increasing powers of 2.

Original entry on oeis.org

1, 5, 7, 15, 19, 35, 43, 75, 91, 155, 187, 315, 379, 635, 763, 1275, 1531, 2555, 3067, 5115, 6139, 10235, 12283, 20475, 24571, 40955, 49147, 81915, 98299, 163835, 196603, 327675, 393211, 655355, 786427, 1310715, 1572859, 2621435, 3145723
Offset: 0

Views

Author

Cino Hilliard, Feb 15 2003

Keywords

Comments

Found as a question on http://mail.python.org/mailman/listinfo/tutor poster: reavey.

Crossrefs

Cf. A079361, A079362, A048488 (bisection).

Programs

  • GAP
    a:=[1,5,7];; for n in [4..30] do a[n]:=a[n-1]+2*a[n-2]-2*a[n-3]; od; a; # G. C. Greubel, Aug 07 2019
  • Magma
    I:=[1,5,7]; [n le 3 select I[n] else Self(n-1) +2*Self(n-2) -2*Self(n-3): n in [1..40]]; // G. C. Greubel, Aug 07 2019
    
  • Maple
    seq(coeff(series((1+4*x)/((1-x)*(1-2*x^2)), x, n+1), x, n), n = 0..40); # G. C. Greubel, Aug 07 2019
  • Mathematica
    LinearRecurrence[{1,2,-2}, {1,5,7}, 40] (* G. C. Greubel, Aug 07 2019 *)
  • PARI
    seq(n) = { j=a=1; p=2; print1(1" "); while(j<=n, a = a + 2^p; print1(a" "); a = a+2^(p-1); print1(a" "); p+=1; j+=2; ) }
    
  • PARI
    a(n)=if(n<0,0,(6-n%2)*2^ceil(n/2)-5)
    
  • Sage
    @CachedFunction
    def a(n):
        if (n==0): return 1
        elif (1<=n<=2): return nth_prime(n+2)
        else: return a(n-1) + 2*a(n-2) - 2*a(n-3)
    [a(n) for n in (0..40)] # G. C. Greubel, Aug 07 2019
    

Formula

a(2n) = 6*2^n - 5, a(2n-1) = 5*(2^n - 1). - Benoit Cloitre, Feb 16 2003
From Colin Barker, Sep 19 2012: (Start)
a(n) = a(n-1) + 2*a(n-2) - 2*a(n-3).
G.f.: (1+4*x)/((1-x)*(1-2*x^2)). (End)

A265113 Primes p such that p and p^2 have the same number of 1's in their binary representations.

Original entry on oeis.org

2, 3, 7, 31, 79, 127, 157, 317, 379, 751, 1087, 1151, 1277, 1279, 1531, 1789, 1951, 2297, 2557, 2927, 3067, 3259, 3319, 3581, 4253, 4349, 5119, 5231, 5503, 5807, 5821, 6271, 6653, 6871, 8191, 8447, 8689, 9209, 10079, 10837, 11597, 11903, 12799, 13309, 13591
Offset: 1

Views

Author

Robert Israel, Dec 01 2015

Keywords

Comments

Primes p such that p^2 is in A089042.
Primes p such that A000120(p) = A000120(p^2).
Contains all terms > 43 in A079361.
Subset of A077436.

Examples

			7 is in the sequence because 7 and 7^2 = 49 have binary representations 111 and 110001 which both have three 1's.
		

Crossrefs

Programs

  • Magma
    [NthPrime(n): n in [1..2000] | Multiplicity({* z: z in Intseq(NthPrime(n)^2, 2) *}, 1) eq &+Intseq(NthPrime(n), 2)]; // Vincenzo Librandi, Dec 02 2015
    
  • Maple
    f:= proc(n) isprime(n) and (convert(convert(n,base,2),`+`) = convert(convert(n^2,base,2),`+`)) end proc:
    select(f, [2,seq(i,i=3..10^5,2)]);
  • Mathematica
    Select[ Prime@ Range@ 1700, DigitCount[n, 2, 1] == DigitCount[n^2, 2, 1],  &] (* Robert G. Wilson v, Dec 01 2015 *)
  • PARI
    c(k, d, b) = {my(c=0, f); while (k>b-1, f=k-b*(k\b); if (f==d, c++); k\=b); if (k==d, c++); return(c)}
    forprime(p=2, 1e5, if(c(p, 1, 2) == c(p^2, 1, 2), print1(p, ", "))) \\ Altug Alkan, Dec 02 2015
Showing 1-2 of 2 results.