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 14 results. Next

A042947 Gilda's numbers: numbers k such that if a Fibonacci sequence is formed with first term = a certain absolute value between decimal digits in k (A007953) and second term = sum of decimal digits in k (A040997), then k itself occurs as a term in the sequence.

Original entry on oeis.org

0, 29, 49, 78, 110, 152, 220, 314, 330, 364, 440, 550, 628, 660, 683, 770, 880, 990, 997, 2207, 5346, 13064, 30254, 35422, 37862, 38006, 65676, 73805, 143662, 202196, 933138, 977909, 3120796, 3242189, 3363582, 3606368, 3727761, 3849154, 3970547, 4484776, 4848955
Offset: 1

Views

Author

Keywords

Comments

Is this sequence infinite?

Crossrefs

Programs

  • Mathematica
    check[abs_, sum_, max_] := Module[{s = {}, a = abs, b = sum, c}, c = b; While[c <= max, id = IntegerDigits[c]; If[c > 10 && abs == Abs[id[[1]] - Total[Rest@id]] && sum == Total[id ], AppendTo[s, c]]; c = a + b; a = b; b = c]; s]; seq[digmax_] := Module[{s = {}}, Do[s = Join[s, check[a, b, 10^digmax]], {a, 0, 10*digmax}, {b, 1, 10*digmax}]; Join[{0}, Sort[s]]]; seq[7] (* Amiram Eldar, Jul 07 2021 *)
  • PARI
    for(n=0,10000000,s=eval(Vec(Str(n)));f1=sum(i=1,#s,s[i]);f0=abs(2*s[1]-f1);f=f0+f1;while(f<=n,if(f==n,print1(n",");break);f0=f1;f1=f;f=f0+f1)) \\ Herman Jamke (hermanjamke(AT)fastmail.fm), Mar 30 2008

Formula

Let [x1.x2.x3. ... .xi] be the decimal expansion of n. Then define F(0) = |x1-x2-...-xi|, F(1) = x1 + x2 + x3 + ... + xi, and for k>1, F(k) = F(k-1) + F(k-2). If F(k)=n for some k, then n belongs to the sequence.

Extensions

Corrected and extended by Larry Reeves (larryr(AT)acm.org), Sep 28 2000
2 more terms from Herman Jamke (hermanjamke(AT)fastmail.fm), Mar 30 2008
Offset corrected by Amiram Eldar, Jul 07 2021

A040115 Concatenate absolute values of differences between adjacent digits of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2, 1, 0, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1
Offset: 0

Views

Author

Keywords

Comments

Let the decimal expansion of n be abcd...efg, say. Then a(n) has decimal expansion |a-b| |b-c| |c-d| ... |e-f| |f-g|. Leading zeros in a(n) are omitted.
From M. F. Hasler, Nov 09 2019: (Start)
This sequence coincides with A080465 up to a(109) but is thereafter completely different.
Eric Angelini calls a(n) the "ghost" of the number n and considers iterations of n -> n +- a(n) depending on parity of a(n), cf. A329200 and A329201. (End)

Examples

			a(371) = 46, for example.
a(110) = 01 = 1, while A080465(110) = 10 - 1 = 9. - _M. F. Hasler_, Nov 09 2019
		

Crossrefs

Cf. A329200, A329201: iterations of n +- a(n).

Programs

  • Mathematica
    Table[FromDigits[Abs[Differences[IntegerDigits[n]]]],{n,110}] (* Harvey P. Dale, Dec 16 2021 *)
  • PARI
    apply( A040115(n)=fromdigits(abs((n=digits(n+!n))[^-1]-n[^1])), [10..199]) \\ Works for all n >= 0. - M. F. Hasler, Nov 09 2019

Formula

a(n) = 0 iff n is a repdigit >= 11 (A010785). - Bernard Schott, May 09 2022

Extensions

Definition clarified by N. J. A. Sloane, Aug 19 2008
Name edited by M. F. Hasler, Nov 09 2019
Terms a(0) = a(1) = ... = a(9) = 0 prepended by Max Alekseyev, Jul 26 2024

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)

A040163 a(n) is the absolute value of (the first digit of n minus the last digit of n).

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2, 1, 0, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 1, 2, 3, 4, 5
Offset: 1

Views

Author

Keywords

Examples

			a(371) = abs(3 - 1) = 2.
a(567) = abs(5 - 7) = 2.
		

Crossrefs

Cf. A000030 (first digit of n), A010879 (last digit of n).

Programs

  • Mathematica
    Array[Abs[First@ # - Last@ #] &@ IntegerDigits@ # &, 106] (* Michael De Vlieger, Oct 15 2018 *)
  • PARI
    a(n) = my(digs = digits(n)); abs(digs[1] - digs[#digs]); \\ Michel Marcus, Sep 27 2013
    
  • PARI
    apply( {A040163(n)=abs(n\10^logint(n+!n,10)-n%10)}, [0..111]) \\ M. F. Hasler, Apr 22 2024
    
  • Python
    for n in range(1,51): print(abs(int(str(n)[0])-int(str(n)[-1]))) # David F. Marrs, Oct 14 2018

Formula

a(n) = abs(floor(n / 10 ^ floor(log_10(n))) - (n - floor(n / 10) * 10)) - David F. Marrs, Oct 14 2018

A156979 Primes p such that 1 = abs(largest digit of p - sum of all the other digits of p).

Original entry on oeis.org

23, 43, 67, 89, 113, 131, 157, 179, 197, 199, 223, 241, 263, 269, 311, 313, 331, 337, 353, 359, 373, 379, 397, 421, 449, 461, 463, 571, 593, 607, 641, 643, 661, 683, 719, 733, 739, 751, 809, 827, 829, 863, 881, 919, 937, 953, 971, 991, 1013, 1031, 1033
Offset: 1

Views

Author

Juri-Stepan Gerasimov, Feb 20 2009

Keywords

Examples

			If prime=197(1<7<9) and 1=abs(9-(1+7)), then 197=a(10). If prime=199(1<9=9) and 1=abs(9-(9+1)), then 199=a(11). If prime=223(2=2<3) and 1=abs(3-(2+2)), then 223=a(12), etc.
		

Crossrefs

Programs

  • Maple
    From R. J. Mathar, Mar 18 2010: (Start)
    A007953 := proc(n) local d ; add(d,d= convert(n,base,10)) ; end proc:
    A054055 := proc(n) local d ; max(op(convert(n,base,10))) ; end proc:
    isA156979 := proc(n) isprime(n) and abs(A007953(n)-2*A054055(n)) = 1 ; end proc:
    for n from 1 to 1050 do if isA156979(n) then printf("%d,",n); end if; end do: (End)
  • Mathematica
    ldodQ[n_]:=Module[{sidn=Sort[IntegerDigits[n]]},Abs[Total[Most[ sidn]]- Last[ sidn]] == 1]; Select[Prime[Range[200]],ldodQ] (* Harvey P. Dale, Nov 13 2013 *)

A040114 List of absolute values of differences between digits of 10, 11, 12, ..., listed digit by digit.

Original entry on oeis.org

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, 2, 1, 0, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5
Offset: 10

Views

Author

Keywords

Comments

Start with the empty sequence. For n = 10, 11, 12, ... do the following. Let the decimal expansion of n be abcd...efg, say. Append the numbers |a-b|, |b-c|, |c-d|, ... |e-f|, |f-g| to the sequence.
The offset is slightly misleading since for n > 99 the index n is in no direct relation with the number whose digits are used to produce a(n), in contrast to A040115 where all digit-differences of n are concatenated, and leading zeros don't appear. For example, a(100) = 1 and a(101) = 0 are the two differences between the digits of 100. Similarly, a(100 + 2k) corresponds to the difference between first and second digit of 100 + k. Therefore, a(120) = 0. - M. F. Hasler, Nov 09 2019

Examples

			From _M. F. Hasler_, Nov 09 2019: (Start)
The first term is the difference between digits of 10, which is 1.
The second term is the difference between digits of 11, which is 0.
The 100th term is the difference between the first two digits of 100, 1-0 = 1.
The 101st term is the difference between the last two digits of 100, 0-0 = 0.
The 120th term is the difference between the first two digits of 110, 1-1 = 0: Here "leading zeros" are preserved, in contrast to A040115 where all digit-wise differences of any n are concatenated to one term, and leading zeros disappear.
(End)
When we reach n = 371, for example, we append 4 and 6 to the sequence.
		

Crossrefs

Programs

  • Mathematica
    Flatten[Table[Abs[Differences[IntegerDigits[n]]],{n,10,200}]] (* Harvey P. Dale, Jun 28 2021 *)

Extensions

Definition clarified by N. J. A. Sloane, Aug 19 2008.
Name edited by M. F. Hasler, Nov 09 2019

A080465 Absolute difference between the two numbers formed by alternate digits of n.

Original entry on oeis.org

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, 2, 1, 0, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 9
Offset: 10

Views

Author

Amarnath Murthy, Mar 02 2003

Keywords

Comments

Differs from A040115 first at a(110) = 9. - R. J. Mathar, Sep 19 2008

Examples

			a(132546) = |124 - 356| = 232.
		

Crossrefs

See also A040997.

Programs

  • PARI
    A080465(n)=abs(vector(#n=digits(n),j,(-1)^j*10^((#n-j)\2))*n~) \\ M. F. Hasler, Jan 10 2016

Extensions

More terms from Ray Chandler, Oct 11 2003

A042939 Absolute values between digits of primes.

Original entry on oeis.org

2, 3, 5, 7, 0, 2, 6, 8, 1, 7, 2, 4, 3, 1, 3, 2, 4, 5, 1, 6, 4, 2, 5, 1, 2, 0, 2, 6, 8, 3, 8, 3, 9, 11, 12, 5, 11, 8, 12, 9, 15, 8, 9, 11, 15, 17, 0, 3, 7, 9, 4, 10, 3, 4, 10, 7, 13, 6, 12, 7, 9, 10, 4, 1, 1, 5, 1, 7, 8, 10, 5, 11, 10, 7, 13, 8, 14, 13, 3, 5, 6, 1, 0, 2, 8, 3, 9, 8, 3, 5, 9, 12, 11, 6
Offset: 1

Views

Author

Keywords

Comments

a(n) = absolute difference between the first digit of prime(n) and the sum of the other digits of prime(n). [Harvey P. Dale, Mar 11 2012]

Crossrefs

Programs

  • Haskell
    a042939 = a040997 . a000040
    -- Reinhard Zumkeller, Oct 10 2012
  • Mathematica
    ddp[n_]:=Module[{idn=IntegerDigits[n]},Abs[First[idn]-Total[Rest[idn]]]]; ddp/@Prime[Range[100]] (* Harvey P. Dale, Mar 11 2012 *)

Formula

If decimal expansion of n-th prime is x1 x2 x3......xk then a(n)=|x1-x2-x3.......-xk|
a(n) = A040997(A000040(n)). - Reinhard Zumkeller, Oct 10 2012

A115261 Prime numbers such that the absolute difference of the sum of their digits in odd positions and the sum of their digits in even positions is also a prime.

Original entry on oeis.org

2, 3, 5, 7, 13, 29, 31, 41, 47, 53, 61, 79, 83, 97, 101, 113, 137, 139, 151, 157, 163, 167, 173, 179, 191, 193, 211, 223, 227, 233, 251, 269, 277, 281, 283, 311, 313, 337, 359, 379, 383, 401, 409, 421, 431, 443, 467, 487, 541, 557, 563, 577, 599, 601, 607, 641
Offset: 1

Views

Author

Keywords

Examples

			1237 is in the sequence because it is prime and abs((7+2)-(3+1)) = 5 is prime
		

Crossrefs

Programs

  • Maple
    Df:=proc(N) j:=1; for n from 1 while j<=N do B:= convert(ithprime(n),base,10); ap:=-(sum(B[2*i],i=1..nops(B)/2)-sum(B[2*n+1],i=0..(nops(B)-1)/2)); if (isprime(abs(ap)) = true) then a[j]:=ithprime(n); j:=j+1; fi; od; end:

A115259 Difference between the sum of digits in odd positions and the sum of digits in even positions of prime numbers.

Original entry on oeis.org

2, 3, 5, 7, 0, 2, 6, 8, 1, 7, -2, 4, -3, -1, 3, -2, 4, -5, 1, -6, -4, 2, -5, 1, -2, 2, 4, 8, 10, 3, 6, -1, 5, 7, 6, -3, 3, -2, 2, -3, 3, -6, -7, -5, -1, 1, 2, 3, 7, 9, 2, 8, -1, -2, 4, -1, 5, -4, 2, -5, -3, -4, 10, 3, 5, 9, 1, 7, 6, 8, 1, 7, 4, -1, 5, -2, 4, 1, 5, 13, 12, 3, 2, 4, 10, 3, 9, 6, -1, 1, 5, 6, 3, -4, 4, 8, 14, 4, 6, 2, 8, 7, 2, 8, -1, 5, 4, -1, 5, 7
Offset: 1

Views

Author

Keywords

Comments

Zero corresponds to the prime 11. It is easy to show that there is no other zero: if the difference of odd-even digits of a number is zero, the number is a multiple of 11, i.e., it is not a prime.
Positions are counted from the least to the most significant digit, so for prime 17 the odd digit is 7 and the even digit is 1. - Harvey P. Dale, Dec 15 2022

Examples

			a(37) = 3 because 37th prime = 157, (7+1) - 5 = 3.
		

Crossrefs

Programs

  • Maple
    A115259 := proc(n) A055017(ithprime(n)) ; end proc: # R. J. Mathar, Aug 26 2011
  • Mathematica
    Table[Total[Take[Reverse[IntegerDigits[p]],{1,-1,2}]]-Total[Take[Reverse[IntegerDigits[p]],{2,-1,2}]],{p,Prime[Range[120]]}] (* Harvey P. Dale, Dec 15 2022 *)

Formula

a(n) = A055017(A000040(n)). - R. J. Mathar, Aug 26 2011
Showing 1-10 of 14 results. Next