Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
A070938
Harshad numbers which terminate in their digital sum.
2
1, 2, 3, 4, 5, 6, 7, 8, 9, 910, 912, 915, 918, 1810, 1812, 1815, 1818, 2710, 2712, 2715, 2718, 3610, 3612, 3615, 3616, 3618, 4510, 4512, 4515, 4518, 5410, 5412, 5415, 5418, 6310, 6312, 6314, 6315, 6318, 7210, 7212, 7215, 7216, 7218, 8110, 8112, 8115, 8118
OFFSET
1,2
LINKS
EXAMPLE
a(12)=915 because it has a digital sum of 15, is divisible by 15 and ends in 15.
MATHEMATICA
hndsQ[n_]:=Module[{ds=Total[IntegerDigits[n]]}, Divisible[n, ds] && Mod[ n, 10^IntegerLength[ds]]==ds]; Select[Range[10000], hndsQ] (* Harvey P. Dale, Dec 24 2011 *)
PROG
(Python)
def ok(n):
s = str(n)
d = sum(map(int, s))
return d and n%d == 0 and s.endswith(str(d))
print([k for k in range(10**4) if ok(k)]) # Michael S. Branicky, Jun 10 2024
CROSSREFS
Cf. A005349.
Sequence in context: A075154 A187924 A352462 * A070594 A121939 A276697
KEYWORD
base,nonn
AUTHOR
Jason Earls, May 12 2002
STATUS
approved