A052217 Numbers whose sum of digits is 3.
3, 12, 21, 30, 102, 111, 120, 201, 210, 300, 1002, 1011, 1020, 1101, 1110, 1200, 2001, 2010, 2100, 3000, 10002, 10011, 10020, 10101, 10110, 10200, 11001, 11010, 11100, 12000, 20001, 20010, 20100, 21000, 30000, 100002, 100011, 100020, 100101
Offset: 1
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..10000 (terms 1..84 from Vincenzo Librandi, terms 85..1140 from T. D. Noe)
Crossrefs
Programs
-
Haskell
a052217 n = a052217_list !! (n-1) a052217_list = filter ((== 3) . a007953) [0..] -- Reinhard Zumkeller, Jul 17 2014
-
Magma
[n: n in [1..100101] | &+Intseq(n) eq 3 ]; // Vincenzo Librandi, Mar 07 2013
-
Mathematica
Union[FromDigits/@Select[Flatten[Table[Tuples[Range[0,3],n],{n,6}],1],Total[#]==3&]] (* Harvey P. Dale, Oct 20 2012 *) Select[Range[10^6], Total[IntegerDigits[#]] == 3 &] (* Vincenzo Librandi, Mar 07 2013 *) Union[Flatten[Table[FromDigits /@ Permutations[PadRight[s, 18]], {s, IntegerPartitions[3]}]]] (* T. D. Noe, Mar 08 2013 *)
-
PARI
isok(n) = sumdigits(n) == 3; \\ Michel Marcus, Dec 28 2015
-
PARI
apply( {A052217_row(n,s,t=-1)=vector(n*(n+1)\2,k,t++>s&&t=!s++;10^(n-1)+10^s+10^t)}, [1..5]) \\ M. F. Hasler, Feb 19 2020
-
Python
from itertools import count, islice def agen(): yield from (10**i + 10**j + 10**k for i in count(0) for j in range(i+1) for k in range(j+1)) print(list(islice(agen(), 40))) # Michael S. Branicky, May 14 2022
-
Python
from math import comb, isqrt from sympy import integer_nthroot def A052217(n): return 10**((m:=integer_nthroot(6*n,3)[0])-(a:=n<=comb(m+2,3)))+10**((k:=isqrt(b:=(c:=n-comb(m-a+2,3))<<1))-((b<<2)<=(k<<2)*(k+1)+1))+10**(c-1-comb(k+(b>k*(k+1)),2)) # Chai Wah Wu, Dec 11 2024
Formula
T(n,k) = 10^(n-1) + 10^A003056(k) + 10^A002262(k) when read as a table with row lengths n*(n+1)/2, n >= 1, 0 <= k < n*(n+1)/2. - M. F. Hasler, Feb 19 2020
Extensions
Offset changed from 0 to 1 by Vincenzo Librandi, Mar 07 2013
Comments