Sum of the digits of n is substring of n: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add Comal) |
|||
Line 1,912: | Line 1,912: | ||
48 such numbers found below 1000. |
48 such numbers found below 1000. |
||
</pre> |
</pre> |
||
=={{header|Yabasic}}== |
|||
<lang Yabasic>// Rosetta Code problem: http://rosettacode.org/wiki/Sum_of_the_digits_of_n_is_substring_of_n |
|||
// by Galileo, 04/2022 |
|||
for n = 0 to 999 |
|||
if isSubstring(n) print n using "####"; |
|||
next |
|||
print |
|||
sub isSubstring(n) |
|||
local n$, lon, i, p |
|||
n$ = str$(n) |
|||
lon = len(n$) |
|||
for i = 1 to lon |
|||
p = p + val(mid$(n$,i,1)) |
|||
next |
|||
return instr(n$, str$(p)) |
|||
end sub</lang> |
|||
{{out}} |
|||
<pre> 0 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100 109 119 129 139 149 159 169 179 189 199 200 300 400 500 600 700 800 900 910 911 912 913 914 915 916 917 918 919 |
|||
---Program done, press RETURN---</pre> |