A058369 Numbers k such that k and k^2 have same digit sum.
0, 1, 9, 10, 18, 19, 45, 46, 55, 90, 99, 100, 145, 180, 189, 190, 198, 199, 289, 351, 361, 369, 379, 388, 450, 451, 459, 460, 468, 495, 496, 550, 558, 559, 568, 585, 595, 639, 729, 739, 775, 838, 855, 900, 954, 955, 990, 999, 1000, 1098, 1099, 1179, 1188, 1189
Offset: 1
Examples
Digit sum of 9 = 9 9^2 = 81, 8+1 = 9 digit sum of 145 = 1+4+5 = 10 145^2 = 21025, 2+1+0+2+5 = 10 digit sum of 954 = 9+5+4 = 18 954^2 = 910116, 9+1+0+1+1+6 = 18. - Florian Roeseler (hazz_dollazz(AT)web.de), May 03 2010
Links
- Zak Seidov, Table of n, a(n) for n = 1..8354 (to a(n) = 10^6)
- Code Golf StackExchange, Equality in the sum of digits, coding challenge started Mar 11 2016.
- K. G. Hare, S. Laishram, and T. Stoll, The sum of digits of n and n^2, International Journal of Number Theory 7:7 (2011), pp. 1737-1752.
- T. D. Noe, Plot of terms up to 10^8
Crossrefs
Programs
-
Haskell
import Data.List (elemIndices) import Data.Function (on) a058369 n = a058369_list !! (n-1) a058369_list = elemIndices 0 $ zipWith ((-) `on` a007953) [0..] a000290_list -- Reinhard Zumkeller, Aug 17 2011
-
Magma
[n: n in [0..1200] |(&+Intseq(n)) eq (&+Intseq(n^2))]; // Vincenzo Librandi, Aug 26 2015
-
Maple
sd := proc (n) options operator, arrow: add(convert(n, base, 10)[j], j = 1 .. nops(convert(n, base, 10))) end proc: a := proc (n) if sd(n) = sd(n^2) then n else end if end proc; seq(a(n), n = 0 .. 1400); # Emeric Deutsch, May 11 2010 select(t -> convert(convert(t,base,10),`+`)=convert(convert(t^2,base,10),`+`), [seq(seq(9*i+j,j=0..1),i=0..1000)]); # Robert Israel, Aug 26 2015
-
Mathematica
Select[Range[0,1200],Total[IntegerDigits[#]]==Total[IntegerDigits[ #^2]]&] (* Harvey P. Dale, Jun 14 2011 *)
-
PARI
is(n)=sumdigits(n)==sumdigits(n^2) \\ Charles R Greathouse IV, Aug 25 2015
-
Python
def ds(n): return sum(map(int, str(n))) def ok(n): return ds(n) == ds(n**2) def aupto(nn): return [m for m in range(nn+1) if ok(m)] print(aupto(1189)) # Michael S. Branicky, Jan 09 2021
Formula
Extensions
Edited by N. J. A. Sloane, May 30 2010
Comments