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

A004159 Sum of digits of n^2.

Original entry on oeis.org

0, 1, 4, 9, 7, 7, 9, 13, 10, 9, 1, 4, 9, 16, 16, 9, 13, 19, 9, 10, 4, 9, 16, 16, 18, 13, 19, 18, 19, 13, 9, 16, 7, 18, 13, 10, 18, 19, 13, 9, 7, 16, 18, 22, 19, 9, 10, 13, 9, 7, 7, 9, 13, 19, 18, 10, 13, 18, 16, 16, 9, 13, 19, 27, 19, 13, 18, 25, 16, 18, 13, 10, 18, 19, 22, 18, 25, 25, 18, 13
Offset: 0

Views

Author

Keywords

Comments

If 3|n then 9|a(n); otherwise, a(n) == 1 (mod 3). - Jon E. Schoenfield, Jun 30 2018

Examples

			Trajectories under the map x -> a(x):
1 ->  1 ->  1 ->  1 ->  1 ->  1 ->  1 ->  1 ->  1 -> ...
2 ->  4 ->  7 -> 13 -> 16 -> 13 -> 16 -> 13 -> 16 -> ...
3 ->  9 ->  9 ->  9 ->  9 ->  9 ->  9 ->  9 ->  9 -> ...
4 ->  7 -> 13 -> 16 -> 13 -> 16 -> 13 -> 16 -> 13 -> ...
5 ->  7 -> 13 -> 16 -> 13 -> 16 -> 13 -> 16 -> 13 -> ...
6 ->  9 ->  9 ->  9 ->  9 ->  9 ->  9 ->  9 ->  9 -> ...
7 -> 13 -> 16 -> 13 -> 16 -> 13 -> 16 -> 13 -> 16 -> ...
- _R. J. Mathar_, Jul 08 2012
		

Crossrefs

Cf. A240752 (first differences), A071317 (partial sums).
Cf. A062685 (smallest square with digit sum n, or 0 if no such square exists).

Programs

  • Haskell
    a004159 = a007953 . a000290  -- Reinhard Zumkeller, Apr 12 2014
    
  • Maple
    read("transforms"):
    A004159 := proc(n)
            digsum(n^2) ;
    end proc: # R. J. Mathar, Jul 08 2012
  • Mathematica
    a004159[n_Integer] := Apply[Plus, IntegerDigits[n^2]]; Table[
    a004159[n], {n, 0, 100}] (* Michael De Vlieger, Jul 21 2014 *)
    Total[IntegerDigits[#]]&/@(Range[0,100]^2) (* Harvey P. Dale, Feb 03 2019 *)
  • PARI
    A004159(n)=sumdigits(n^2) \\ M. F. Hasler, Sep 23 2014
  • Python
    def A004159(n):
        return sum(int(d) for d in str(n*n)) # Chai Wah Wu, Sep 03 2014
    

Formula

a(n) = A007953(A000290(n)); a(A058369(n)) = A007953(A058369(n)). - Reinhard Zumkeller, Apr 25 2009
a(10n) = a(n). If n > 1 is not a multiple of 10, then a(n)=4 iff n = 10^k+1 = A062397(k), a(n)=7 iff n is in A215614={4, 5, 32, 49, 149, 1049}, and else a(n) >= 9. - M. F. Hasler, Sep 23 2014

A202089 Numbers n such that n^2 and (n+1)^2 have same digit sum.

Original entry on oeis.org

4, 13, 22, 49, 58, 76, 103, 130, 139, 157, 193, 202, 229, 247, 256, 274, 283, 301, 391, 418, 427, 454, 463, 472, 481, 508, 526, 553, 598, 607, 616, 643, 661, 679, 688, 724, 733, 742, 760, 769, 778, 796, 850, 868, 877, 886, 904, 913, 931, 949, 958, 976, 1003
Offset: 1

Views

Author

Zak Seidov, Dec 11 2011

Keywords

Comments

Or numbers n such that A004159(n)=A004159(n+1), or A007953(n^2)=A007953((n+1)^2).
Corresponding digit sums are of the form 7+9k, with k=1, 2, 3,... .
Numbers n are of the form 4+9m, with m=0, 1, 2, 5, 6, 8, 11, ... .
A240752(a(n)) = 0. - Reinhard Zumkeller, Apr 12 2014

Examples

			4^2=16 and 5^2=25 have same digit sum ds=7.
13^2=169 and 14^2=196 have ds=16.
76^2=5776 and 77^2=5929 have ds=25.
526^2=276676 and 527^2=277729 have ds=34.
		

Crossrefs

Programs

  • Haskell
    import Data.List (elemIndices)
    a202089 n = a202089_list !! (n-1)
    a202089_list = elemIndices 0 a240752_list
    -- Reinhard Zumkeller, Apr 12 2014
    
  • Mathematica
    cnt = 0; nn = 10000; n = 4; Reap[While[cnt < nn, While[Total[IntegerDigits[n^2]] != Total[IntegerDigits[(n + 1)^2]], n = n + 9]; cnt++; Sow[n]; n = n + 9]][[2, 1]]
  • Python
    def ok(n): return sum(map(int, str(n*n))) == sum(map(int, str((n+1)**2)))
    print(list(filter(ok, range(1004)))) # Michael S. Branicky, Apr 13 2021

A239878 Numbers k with digit_sum(k*k) + 1 = digit_sum((k+1)*(k+1)).

Original entry on oeis.org

0, 18, 27, 36, 45, 72, 81, 108, 153, 198, 216, 225, 243, 252, 270, 297, 306, 342, 369, 396, 423, 441, 450, 477, 486, 495, 504, 513, 522, 549, 558, 576, 603, 630, 639, 657, 693, 702, 729, 747, 756, 783, 801, 846, 891, 918, 954, 963, 972, 981
Offset: 1

Views

Author

Reiner Moewald, Mar 28 2014

Keywords

Comments

All terms are divisible by 9.
The number of terms is unlimited: n = 3*10^z + 6, i.e., digit_sum(n*n) + 1 = 27 + 1 = 28 = digit_sum((n+1)*(n+1)). - Reiner Moewald, Apr 20 2014

Crossrefs

Programs

  • Haskell
    import Data.List (elemIndices)
    a239878 n = a239878_list !! (n-1)
    a239878_list = elemIndices 1 a240752_list
    -- Reinhard Zumkeller, Apr 12 2014
  • PARI
    isok(n) = (sumdigits(n^2) + 1) == sumdigits((n+1)^2); \\ Michel Marcus, Apr 06 2014
    
  • Python
    def digit_Sum(n):
       integerString = str(n)
       digit_Sum=0
       for digitLetter in integerString:
          digit_Sum = digit_Sum + int(digitLetter)
       return digit_Sum
    count = 0;
    for i in range(20000):
       if(digit_Sum(i*i) + 1 == digit_Sum((i+1)*(i+1))):
          count = count +1
          print(count,"   ",i)
    

Formula

A240752(a(n)) = 1. - Reinhard Zumkeller, Apr 12 2014

A240754 Numbers k with digit_sum(k*k) - 1 = digit_sum((k+1)*(k+1)).

Original entry on oeis.org

8, 26, 53, 98, 107, 143, 161, 170, 179, 188, 224, 233, 242, 260, 269, 278, 287, 296, 350, 368, 386, 404, 413, 431, 449, 476, 494, 503, 539, 548, 557, 584, 593, 629, 638, 647, 674, 683, 737, 746, 773, 791, 818, 827, 863, 872, 908, 926, 944, 998, 1007, 1043
Offset: 1

Views

Author

Reinhard Zumkeller, Apr 12 2014

Keywords

Comments

A240752(a(n)) = 0.

Crossrefs

Programs

  • Haskell
    import Data.List (elemIndices)
    a240754 n = a240754_list !! (n-1)
    a240754_list = elemIndices (-1) a240752_list
    
  • Python
    def ds(n): return sum(map(int, str(n)))
    def ok(n): return ds(n*n) - 1 == ds((n+1)*(n+1))
    print(list(filter(ok, range(1044)))) # Michael S. Branicky, Aug 26 2021
Showing 1-4 of 4 results.