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

Add PL/I
(Added AutoHotkey)
(Add PL/I)
Line 1,140:
Found 365 such numbers < 10001: 0, 1, 2, 3, 4, ..., 9926, 9927, 9928, 9929, 10000
</pre>
 
=={{header|PL/I}}==
<lang pli>sumOfDigitsIsSubstring: procedure options(main);
digitSum: procedure(n) returns(fixed);
declare (ds, x, n) fixed;
ds = 0;
do x=n repeat(x/10) while(x>0);
ds = ds + mod(x, 10);
end;
return(ds);
end digitSum;
chop: procedure(n) returns(fixed);
declare (i, n) fixed;
i = 1;
do while(i<n);
i = i * 10;
end;
i = i/10;
if i=0 then return(0);
else return(mod(n, i));
end chop;
infix: procedure(n, h) returns(bit) recursive;
declare (n, h) fixed;
if n=h then return('1'b);
if h=0 then return('0'b);
if infix(n, h/10) then return('1'b);
return(infix(n, chop(h)));
end infix;
declare (i, col) fixed;
col = 0;
do i=0 to 999;
if infix(digitSum(i), i) then do;
put edit(i) (F(5));
col = col + 1;
if mod(col, 10)=0 then put skip;
end;
end;
put skip;
end sumOfDigitsIsSubstring;</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</pre>
 
=={{header|PL/M}}==
2,094

edits