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.

User: Adam Kertesz

Adam Kertesz's wiki page.

Adam Kertesz has authored 11 sequences. Here are the ten most recent ones:

A303744 Numbers that are not a difference between same powers (greater than 1) of positive numbers.

Original entry on oeis.org

1, 2, 4, 6, 10, 14, 18, 22, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 142, 146, 150, 154, 158, 162, 166, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 222, 226, 230, 234, 238, 246, 250, 254, 258, 262, 266, 270, 274, 278, 282, 286, 290
Offset: 1

Author

Adam Kertesz, Apr 29 2018

Keywords

Comments

Apart from 1 and 4, all terms == 2 (mod 4). - Robert Israel, Jun 25 2018

Examples

			Odd numbers greater than 1 are differences of squares, so they are not here.
8 is not a term, 9 - 1: difference of two squares;
26 is not a term, 27 - 1: difference of two cubes.
		

Crossrefs

Sequences of numbers that are difference of powers: A024352 (squares), A181123 (cubes).
And of further n-th powers: A147857 (4th), A181124 (5th), A181125 (6th), A181126 (7th), A181127 (8th), A181128 (9th).

Programs

  • Maple
    N:= 1000: # to get all terms <= N
    S:= {1,2,4,seq(i,i=6..N,4)}:
    for p from 3 to ilog2(N+1) do
      for n from 1 while n^p - (n-1)^p <= N do
        if n^p > N then m0:= ceil((n^p - N)^(1/p)) else m0:= 1 fi;
        for m from m0 to n-1 do
          v:= n^p-m^p;
          S:= S minus {v};
        od
    od od:
    sort(convert(S,list)); # Robert Israel, Jun 25 2018

A262598 Small positive integer solutions of the simultaneous equations y = ax + b and y^2 = ax^3 + b.

Original entry on oeis.org

1, 2, 1, 3, 1, 6, 9, 15, 2, 5, 6, 16, 2, 6, 9, 21, 2, 10, 25, 45, 2, 57, 495, 609, 2, 637, 21463, 22737, 3, 10, 25, 55, 3, 14, 49, 91, 4, 14, 49, 105, 4, 18, 81, 153, 5, 13, 40, 105, 5, 18, 81, 171, 5, 22, 121, 231, 5, 574, 27881, 30751, 6, 22, 121, 253, 6, 26, 169, 325
Offset: 1

Author

Keywords

Comments

The b-file contains all solutions for 1<=a<=100 and 1<=x<=2000000, double-checked by APL and Maple programs.
Of the 224 solutions:
100 are of the form (a, 2(2a-1), (2a-1)^2, (4a-1)(2a-1));
100 are of the form (a, 2(2a+1), (2a+1)^2, (4a+1)(2a+1));
6 are of the form (F(k), F(k+2), F(k)*F(k+1), F(k)*F(k+3)),
where F(n) is the n-th Fibonacci number and k is odd;
(1, 2, 1, 3) is of both forms (a, 2(2a-1), (2a-1)^2, (4a-1)(2a-1)) and (F(k), F(k+2), F(k)*F(k+1), F(k)*F(k+3));
19 have the form (a, cs, c^2t, cu) but appear to be otherwise unrelated.

Examples

			The sequence is the result of concatenating the rows in the table of solutions for a, x, b and y. The table starts:
.  a      x      b      y
.  1      2      1      3
.  1      6      9     15
.  2      5      6     16
.  2      6      9     21
.  2     10     25     45
.  2     57    495    609
.  2    637  21463  22737
.  3     10     25     55
.  3     14     49     91
.  4     14     49    105
.  4     18     81    153
.  5     13     40    105
.  5     18     81    171
.  5     22    121    231
.  5    574  27881  30751
.  6     22    121    253
.  6     26    169    325
For a=7 the three solution quadruplets are (7,26,169,351), (7,30,225,435) and (7,1340,120400,129780).
		

Programs

  • Maple
    for a to 100 do
       for x to 2000000 do
          y := ceil(sqrt(a*x^3));
          b := y^2-a*x^3;
          if b > 0 and y = a*x+b then
             printf("%10d   %10d   %10d   %10d\n", a, x, b, y);
          end if;
       end do;
    end do;

A179482 A subset of vampire numbers: n has a nontrivial factorization using n's digits in reverse order.

Original entry on oeis.org

126, 153, 688, 1395, 33579, 37668, 187029, 223524, 267034, 1008126, 1480368, 1514955, 1574253, 1766196, 1791495, 1831086, 1945944, 2784384, 10013323, 10353244, 18937617, 19437888, 23486976, 36528975, 38477586, 45334998, 48471696, 109019911, 116257833
Offset: 1

Author

Adam Kertesz, Jul 16 2010

Keywords

Comments

A subset of A020342.
Easy to prove that no vampire number has a factorization with n's digits in "normal" (left-to-right) order, so it was natural to search if any of the reverse order works.
A superset of A009944,permitting two or more(!) factors. [Adam Kertesz, Aug 07 2010]
Sequence is infinite, since it is a superset of A009944 which is infinite (see Comments at A009944). - Giovanni Resta, Mar 17 2013

Examples

			E.g. 126=6*21, 1395=5*9*31, 267034=4307*62.
		

Crossrefs

Extensions

a(10)-a(29) from Giovanni Resta, Mar 17 2013

A119706 Total length of longest runs of 1's in all bitstrings of length n.

Original entry on oeis.org

1, 4, 11, 27, 62, 138, 300, 643, 1363, 2866, 5988, 12448, 25770, 53168, 109381, 224481, 459742, 939872, 1918418, 3910398, 7961064, 16190194, 32893738, 66772387, 135437649, 274518868, 556061298, 1125679616, 2277559414, 4605810806, 9309804278, 18809961926
Offset: 1

Author

Adam Kertesz, Jun 09 2006, Jun 13 2006

Keywords

Comments

a(n) divided by 2^n is the expected value of the longest run of heads in n tosses of a fair coin.
a(n) is also the sum of the number of binary words with at least one run of consecutive 0's of length >= i for i>=1. In other words A000225 + A008466 + A050231 + A050232 + ... . - Geoffrey Critzer, Jan 12 2013

Examples

			a(3)=11 because for the 8(2^3) possible runs 0 is longest run of heads once, 1 four times, 2 two times and 3 once and 0*1+1*4+2*2+3*1 = 11.
		

References

  • A. M. Odlyzko, Asymptotic Enumeration Methods, pp. 136-137
  • R. Sedgewick and P. Flajolet, Analysis of Algorithms, Addison Wesley, 1996, page 372.

Crossrefs

Cf. A334833.

Programs

  • Maple
    A038374 := proc(n) local nshft, thisr, resul; nshft := n ; resul :=0 ; thisr :=0 ; while nshft > 0 do if nshft mod 2 <> 0 then thisr := thisr+1 ; else resul := max(resul, thisr) ; thisr := 0 ; fi ; nshft := floor(nshft/2) ; od ; resul := max(resul, thisr) ; RETURN(resul) ; end : A119706 := proc(n) local count, c, rlen ; count := array(0..n) ; for c from 0 to n do count[c] := 0 ; od ; for c from 0 to 2^n-1 do rlen := A038374(c) ; count[rlen] := count[rlen]+1 ; od ; RETURN( sum('count[c]*c','c'=0..n) ); end: for n from 1 to 40 do print(n,A119706(n)) ; od : # R. J. Mathar, Jun 15 2006
    # second Maple program:
    b:= proc(n, m) option remember; `if`(n=0, 1,
          `if`(m=0, add(b(n-j, j), j=1..n),
          add(b(n-j, min(n-j, m)), j=1..min(n, m))))
        end:
    a:= proc(n) option remember;
         `if`(n<2, n, 2*a(n-1) +b(n, 0))
        end:
    seq(a(n), n=1..40);  # Alois P. Heinz, Dec 19 2014
  • Mathematica
    nn=10;Drop[Apply[Plus,Table[CoefficientList[Series[1/(1-2x)-(1-x^n)/(1-2x+x^(n+1)),{x,0,nn}],x],{n,1,nn}]],1]  (* Geoffrey Critzer, Jan 12 2013 *)

Formula

a(n+1) = 2*a(n) + A007059(n+2)
a(n) > 2*a(n-1). a(n) = Sum_{i=1..(2^n)-1} A038374(i). - R. J. Mathar, Jun 15 2006
From Geoffrey Critzer, Jan 12 2013: (Start)
O.g.f.: Sum_{k>=1} 1/(1-2*x) - (1-x^k)/(1-2*x+x^(k+1)). - Corrected by Steven Finch, May 16 2020
a(n) = Sum_{k=1..n} A048004(n,k) * k.
(End)
Conjecture: a(n) = A102712(n+1)-2^n. - R. J. Mathar, Jun 05 2025

Extensions

More terms from R. J. Mathar, Jun 15 2006
Name edited by Alois P. Heinz, Mar 18 2020

A118119 Smallest integer m for which gcd(m^n + 1, (m+1)^n + 1) > 1.

Original entry on oeis.org

2, 5, 8, 6, 2, 4, 5, 2, 2, 10, 8, 6, 2, 3, 6, 14, 2, 37, 6, 2, 2, 10, 2, 6, 2, 2, 6, 10, 2, 52, 22, 2, 2, 4, 8, 26, 2, 3, 5, 5, 2, 24, 6, 2, 2, 32, 6, 4, 2, 2, 8, 5, 2, 6, 5, 4, 2, 230, 2, 44, 2, 2, 17, 4, 2, 55, 5, 2, 2, 34, 2, 9, 2, 3, 8, 4, 2, 6, 6, 2, 2, 2, 3
Offset: 2

Author

Adam Kertesz, May 12 2006; May 13 2006

Keywords

Comments

Let f(x) := x^n + c and g(x) := (x+1)^n + c. It can be shown that there exists an integer polynomial s(x) and t(x) such that s(x) f(x) + t(x) g(x) = resultant(f, g) for all x. Let p be a prime number such that f(x_0) == 0 (mod p) and g(x_0) == 0 (mod p) for some x_0 in Z/pZ. Then, s(x_0) f(x_0) + t(x_0) g(x_0) == 0 == resultant(f,g) (mod p). So, p|resultant(f,g). If gcd(f(x_0), g(x_0)) > 1 for some integer x_0, there exists a prime number p which divides gcd(f(x_0), g(x_0)). We can assume that p is a prime factor of resultant(f,g). Let S be a set of x (in Z/pZ) such that x^n == -c (mod p). If we are able to find consecutive terms y, y+1 in S, then y is one of the solutions such that gcd(f(y),g(y)) > 1. - Hiroaki Yamanouchi, Mar 11 2015

Examples

			a(3)=5 because gcd(2 = 1^3 + 1, 9 = 2^3 + 1) = gcd(9, 28) = gcd(28, 65) = gcd(65, 126) = 1 and gcd(126 = 5^3 + 1, 217 = 6^3 + 1) = 7 > 1.
		

Crossrefs

Sequences of smallest m with gcd(m^n + c, (m+1)^n + c) > 1: A255852 (c=2), A255853 (c=3), A255854 (c=4), A255855 (c=5), A255856 (c=6), A255857 (c=7), A255858 (c=8), A255859 (c=9), A255860 (c=10), A255861 (c=11), A255862 (c=12), A255863 (c=13), A255864 (c=14), A255865 (c=15), A255866 (c=16), A255867 (c=17), A255868 (c=18), A255869 (c=19)

Programs

  • Maple
    A118119 := proc(n) local k ,g; for k from 1 do g := igcd(k^n+1,(k+1)^n+1) ; if g>1 then return k ; end if; end do: end proc: # R. J. Mathar, Mar 07 2011
  • Mathematica
    A118119[n_] := Module[{m = 1}, While[GCD[m^n + 1, (m + 1)^n + 1] <= 1, m++]; m]; Table[A118119[n], {n, 2, 50}] (* Robert Price, Oct 15 2018 *)
  • PARI
    { a(n,c=1) = my(f,g); g=gcdext(x^n+c,(x+1)^n+c); f = factor(lcm(denominator(content(g[1])),denominator(content(g[2]))))[,1]; g=[]; for(i=1,#f, g=concat(g, apply(lift, polrootsmod( gcd([x^n+c,(x+1)^n+c]*Mod(1,f[i])), f[i] ) )); );vecmin(g); }  \\ Max Alekseyev, Aug 06 2015
    
  • PARI
    \\ This naive form is typically faster than the polynomial gcd method above. Perhaps a combined algorithm which tries this first before calling the other would be fastest.
    a(n)=for(m=2,oo, if(gcd(m^n + 1, (m+1)^n + 1)>1, return(m))) \\ Charles R Greathouse IV, May 08 2024
    
  • Python
    from itertools import count
    from math import gcd
    def A118119(n): return next(filter(lambda m:gcd(m**n+1,(m+1)**n+1)>1,count(1))) # Chai Wah Wu, May 08 2024

Extensions

Edited by Max Alekseyev, Aug 06 2015

A069581 Triangle T(m,n) giving number of unit fractions (with odd denominators) needed to represent m/n, rational (n odd), using the greedy algorithm.

Original entry on oeis.org

2, 2, 3, 4, 4, 3, 4, 3, 4, 2, 1, 2, 3, 2, 3, 4, 6, 3, 2, 3, 4, 5, 4, 5, 6, 2, 3, 10, 3, 4, 3, 4, 3, 6, 9, 6, 2, 1, 2, 1, 2, 3, 2, 3, 2, 3, 4, 3, 4, 2, 5, 4, 5, 2, 3, 4, 7, 6, 5, 4, 5, 10, 5, 6, 6, 3, 2, 5, 4, 3, 4, 5, 4, 7, 6, 3, 4, 5, 6, 7, 6, 2, 1, 2, 3, 4, 1, 2, 3, 2, 3, 4, 5, 2, 3, 4, 3, 4, 5, 6, 6, 5, 4
Offset: 3

Author

Adam Kertesz, Apr 24 2002

Keywords

Comments

If m/n, a rational number (n odd) is expressed as sum (1/xi), where the xi are successively chosen to be the least possible odd integers which leave a nonnegative remainder, is the sum always finite? My conjecture: odd m needs odd, even m needs even unit fractions. In the triangle: rows are the (odd) denominators, columns are 1

Examples

			T(2/7) = 4 because 2/7 = 1/5 + 1/13 + 1/115 + 1/10465.
2/3; 2/5 3/5 4/5; 2/7 3/7 4/7 5/7 6/7; 2/9 3/9 4/9 5/9 6/9 7/9 8/9
Triangle begins:
2;
2, 3, 4;
4, 3, 4, 3, 4;
2, 1, 2, 3, 2, 3, 4;
...
		

References

  • R. K. Guy: Unsolved Problems in Number Theory, Second edition, Springer- Verlag, 1994, D11.

A058188 Number of primes between prime(n) and prime(n) + sqrt(prime(n)), where prime(n) is the n-th prime.

Original entry on oeis.org

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

Author

Adam Kertesz, Dec 04 2000

Keywords

Comments

Conjecture: if prime(n)>=127, there is always at least one prime between prime(n) and prime(n) + sqrt(prime(n)). Easily checked for prime(n)<1.1e15 in existing maximal gap tables

Examples

			a(12) = 2 because between p(12)= 37 and 37+sqrt(37) = 43.08 there are two primes: 41 and 43
		

References

  • R. K. Guy: Unsolved problems in number theory, 2nd ed., Springer-Verlag,1994; Sections A8, A 9.
  • Paulo Ribenboim: The little book of big primes, Springer-Verlag,1991; 142ff

Crossrefs

Cf. A030296.

Programs

  • Mathematica
    Table[PrimePi[p+Sqrt[p]]-PrimePi[p],{p,Prime[Range[100]]}] (* Harvey P. Dale, Mar 13 2023 *)
  • PARI
    a(n) = my(p=prime(n)); primepi(p+sqrtint(p)) - n; \\ Michel Marcus, Jun 21 2017

A076044 Largest a(n) values with at most n primes between a(n) and a(n)+sqrt(a(n)) inclusive.

Original entry on oeis.org

116, 1330, 2481, 2558, 5929, 7371, 9961, 10743, 23378, 35608, 35612, 38361, 44286, 46902, 69503, 69545, 88024, 107359, 110087, 110099, 113386, 126860, 250172, 250180, 250186, 250202, 267969, 267975, 285846, 285858, 302013, 302017, 360346, 369213, 404562, 404574, 484650, 484654, 514893, 561443, 561481, 561509, 561533, 638194, 638208, 650020, 682490, 713634, 713636
Offset: 0

Author

Adam Kertesz, Oct 28 2002

Keywords

Comments

Conjecture: for every m greater than a(n), there are more than n primes between m and m+sqrt(m); true if a(n) less than 1000000.

Examples

			a(3)=2558 because there are three primes between 2558 and int(2558+sqrt 2558)= 2608 and for every larger number there are more than 3 primes in the respective interval.
		

References

  • P. Ribenboim, The Little Book of Big Primes, Springer-Verlag, 1991, p. 143

A056240 Smallest number whose prime divisors (taken with multiplicity) add to n.

Original entry on oeis.org

2, 3, 4, 5, 8, 7, 15, 14, 21, 11, 35, 13, 33, 26, 39, 17, 65, 19, 51, 38, 57, 23, 95, 46, 69, 92, 115, 29, 161, 31, 87, 62, 93, 124, 155, 37, 217, 74, 111, 41, 185, 43, 123, 86, 129, 47, 215, 94, 141, 188, 235, 53, 329, 106, 159, 212, 265, 59, 371, 61, 177, 122
Offset: 2

Author

Adam Kertesz, Aug 19 2000

Keywords

Comments

a(n) is the index of first occurrence of n in A001414.
From David James Sycamore and Michel Marcus, Jun 16 2017, Jun 28 2017: (Start)
Recursive calculation of a(n):
For prime p, a(p) = p.
For even composite n, let P_n denote the largest prime < n-1 such that n-P_n is prime (except if n = 6).
For odd composite n, let P_n denote the largest prime < n-1 such that n-3-P_n is prime.
Conjecture: a(n) = min { q*a(n-q); q prime, P_n <= q < n-1 }.
Examples:
For n = 9998, P_9998 = 9967 and a(9998) = min { 9973*a(25), 9967*a(31) } = 9967*31 = 308977.
For n = 875, P_875 = 859 and a(875) = min { 863*a(12), 859*a(16) } = 863*35 = 30205.
Note: A000040 and A288313 are both subsequences of this sequence. (End)

Examples

			a(8) = 15 = 3*5 because 15 is the smallest number whose prime divisors sum to 8.
a(10000) = 586519: Let pp(n) be the largest prime < n and the candidate being the current value that might be a(10000). Then we see that pp(10000 - 1) = 9973, giving a candidate 9973 * a(10000 - 9973) = 9973 * 92. pp(9973) = 9967, giving a candidate 9967 * a(10000 - 9967) = 9967 * 62. pp(9967) = 9949, giving the candidate 9949 * a(10000 - 9949) = 9962 * 188. This is larger than our candidate so we keep 9967 * 62 as our candidate. pp(9949) = 9941, giving a candidate 9941 * pp(10000 - 9941) = 9941 * 59. We see that (n - p) * a(p) >= (n - p) * p > candidate = 9941 * 59 for p > 59 so we stop iterating to conclude a(10000) = 9941 * 59 = 586519. - _David A. Corneth_, Mar 23 2018, edited by _M. F. Hasler_, Jan 19 2019
		

Crossrefs

First column of array A064364, n>=2.
See A000792 for the maximal numbers whose prime factors sums up to n.

Programs

  • Haskell
    a056240 = (+ 1) . fromJust . (`elemIndex` a001414_list)
    -- Reinhard Zumkeller, Jun 14 2012
    
  • Maple
    A056240 := proc(n)
        local k ;
        for k from 1 do
            if A001414(k) = n then
                return k ;
            end if;
        end do:
    end proc:
    seq(A056240(n),n=2..80) ; # R. J. Mathar, Apr 15 2024
  • Mathematica
    a = Table[0, {75}]; Do[b = Plus @@ Flatten[ Table[ #1, {#2}] & @@@ FactorInteger[n]]; If[b < 76 && a[[b]] == 0, a[[b]] = n], {n, 2, 1000}]; a (* Robert G. Wilson v, May 04 2002 *)
    b[n_] := b[n] = Total[Times @@@ FactorInteger[n]];
    a[n_] := For[k = 2, True, k++, If[b[k] == n, Return[k]]];
    Table[a[n], {n, 2, 63}] (* Jean-François Alcover, Jul 03 2017 *)
  • PARI
    isok(k, n) = my(f=factor(k)); sum(j=1, #f~, f[j,1]*f[j,2]) == n;
    a(n) = my(k=2); while(!isok(k, n), k++); k; \\ Michel Marcus, Jun 21 2017
    
  • PARI
    a(n) = {if(n < 7, return(n + 2*(n==6))); my(p = precprime(n), res); if(p == n, return(p), p = precprime(n - 2); res = p * a(n - p); while(res > (n - p) * p && p > 2, p = precprime(p - 1); res = min(res, a(n - p) * p)); res)} \\ David A. Corneth, Mar 23 2018
    
  • PARI
    A056240(n, p=n-1, m=oo)=if(n<6 || isprime(n), n, n==6, 8, until(p<3 || (n-p=precprime(p-1))*p >= m=min(m,A056240(n-p)*p),); m) \\ M. F. Hasler, Jan 19 2019

Formula

Trivial but essential: a(n) >= n. - David A. Corneth, Mar 23 2018
a(n) >= n with equality iff n = 4 or n is prime. - M. F. Hasler, Jan 19 2019

Extensions

More terms from James Sellers, Aug 25 2000

A048298 a(n) = n if n=2^i for i >= 0, otherwise a(n) = 0.

Original entry on oeis.org

0, 1, 2, 0, 4, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 0

Author

Keywords

Comments

Expand x/(x-1) = Sum_{n >= 0} 1/x^n as Sum a(n) / (1+x^n).
Nim-binomial transform of the natural numbers. If {t(n)} is the Nim-binomial transform of {a(n)}, then t(n)=(S^n)a(0), where Sf(n) denotes the Nim-sum of f(n) and f(n+1); and S^n=S(S^(n-1)). - John W. Layman, Mar 06 2001

Crossrefs

A kind of inverse to A048272. Cf. A060147.
This is Guy Steele's sequence GS(5, 1) (see A135416).
Cf. A209229 (characteristic function of powers of 2).

Programs

  • Haskell
    a048298 n = a209229 n * n  -- Reinhard Zumkeller, Oct 17 2015
    
  • Magma
    [n eq 2^Valuation(n,2) select n else 0: n in [0..120]]; // Vincenzo Librandi, improved by Bruno Berselli, Mar 27 2015
    
  • Maple
    0, seq(op([2^n,0$(2^n-1)]), n=0..10); # Robert Israel, Mar 25 2015
    a := n -> if n = 2^ilog2(n) then n else 0 fi: # Peter Luschny, Oct 03 2022
  • Mathematica
    Table[n*Boole[Or[n == 1, First /@ FactorInteger@ n == {2}]], {n, 0, 120}] (* Michael De Vlieger, Mar 25 2015 *)
    a[n_] := If[n == 2^IntegerExponent[n, 2], n, 0]; Array[a, 100, 0] (* Amiram Eldar, Oct 10 2023 *)
  • PARI
    a(n)=direuler(p=1,n,if(p==2,1/(1-2*X),1))[n] /* Ralf Stephan, Mar 27 2015 */
    
  • PARI
    a(n) = if(n == 0, 0, if(n == 1 << valuation(n, 2), n, 0)); \\ Amiram Eldar, Oct 10 2023
    
  • Python
    def A048298(n): return n if n and not(n&-n)^n else 0 # Chai Wah Wu, Dec 01 2022

Formula

Multiplicative with a(2^e)=2^e and a(p^e)=0 for p > 2. - Vladeta Jovovic, Jan 27 2002
Inverse mod 2 binomial transform of n. a(n) = sum{k=0..n, (-1)^A010060(n-k)*mod(C(n, k), 2)*k}. - Paul Barry, Jan 03 2005
If n=1 we have a(n)=1; if n=p is prime, then (-1)^(p+1)+a(p)=1, thus a(2)=2, and a(p)=0, if p>2. - Vladimir Shevelev, Jun 09 2009
Dirichlet g.f.: 2^s/(2^s-2). - Ralf Stephan, Jun 17 2007
Dirichlet g.f.: zeta(s)/eta(s). - Ralf Stephan, Mar 25 2015
For n>=1, we have a recursion Sum_{d|n}(-1)^(1+(n/d))a(d)=1. - Vladimir Shevelev, Jun 09 2009
For n>=1, there is the recurrence n=Sum_{k=1..n} a(k)*g(n/k) where g(x) = floor(x) - 2*floor(x/2). - Benoit Cloitre, Nov 11 2010
a(n) = A209229(n)*n. - Reinhard Zumkeller, Oct 17 2015
a(n) = n if 2^n mod n == 0 and a(n) = 0 otherwise. - Chai Wah Wu, Dec 01 2022

Extensions

More terms from Keiko L. Noble (s1180624(AT)cedarville.edu)