A380725 Positive integers k whose sum of digits equals the square of their number of digits.
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
Links
- Anwar Hahj Jefferson-George, Table of n, a(n) for n = 1..74583
Programs
-
Mathematica
Select[Range[1200],DigitSum[#]==IntegerLength[#]^2&] (* James C. McMahon, Feb 18 2025 *)
-
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
-
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) }
Comments