login
A380725
Positive integers k whose sum of digits equals the square of their number of digits.
0
1, 13, 22, 31, 40, 108, 117, 126, 135, 144, 153, 162, 171, 180, 207, 216, 225, 234, 243, 252, 261, 270, 306, 315, 324, 333, 342, 351, 360, 405, 414, 423, 432, 441, 450, 504, 513, 522, 531, 540, 603, 612, 621, 630, 702, 711, 720, 801, 810, 900, 1069, 1078, 1087, 1096, 1159, 1168, 1177, 1186, 1195
OFFSET
1,2
COMMENTS
This is a finite sequence since if k is L digits long then its sum of digits is at most 9*L which is < L^2 for L > 9.
LINKS
Anwar Hahj Jefferson-George, Table of n, a(n) for n = 1..74583
MATHEMATICA
Select[Range[1200], DigitSum[#]==IntegerLength[#]^2&] (* James C. McMahon, Feb 18 2025 *)
PROG
(Rust)
/// Is the term a valid entry in a380725
pub fn a380725_predicate(mut k: usize) -> bool {
let base = 10usize;
let mut len = 0usize;
let mut digit_sum = 0usize;
while k > 0 {
let digit = k.rem_euclid(base);
k /= base;
digit_sum += digit;
len += 1;
}
digit_sum == len.pow(2u32)
}
(PARI) isok(k) = my(d=digits(k)); vecsum(d) == sqr(#d); \\ Michel Marcus, Feb 08 2025
(Python)
def ok(n): return sum(map(int, s:=str(n))) == len(s)**2
print([k for k in range(2000) if ok(k)]) # Michael S. Branicky, Feb 08 2025
CROSSREFS
Cf. A007953 (sum of digits), A061384.
Sequence in context: A351291 A374254 A336263 * A059408 A164455 A164504
KEYWORD
nonn,base,fini,full,easy,new
AUTHOR
STATUS
approved