Sum of the digits of n is substring of n: Difference between revisions

Content added Content deleted
mNo edit summary
Line 30: Line 30:


=={{header|Julia}}==
=={{header|Julia}}==
<lang julia># Find and show numbers n with property that the sum of the digits of n is substring of n, where n < 1000
<lang julia>issumsub(n, base=10) = occursin(string(sum(digits(n, base=base)), base=base), string(n, base=base))

issumsub(n, base=10) = occursin(string(sum(digits(n, base=base)), base=base), string(n, base=base))


foreach(p -> print(rpad(p[2], 4), p[1] % 10 == 0 ? "\n" : ""), enumerate(filter(issumsub, 0:999)))
foreach(p -> print(rpad(p[2], 4), p[1] % 10 == 0 ? "\n" : ""), enumerate(filter(issumsub, 0:999)))