Sum of the digits of n is substring of n: Difference between revisions
Content added Content deleted
m (added whitespace and highlighting, added related tasks.) |
(→{{header|ALGOL W}}: spell isContained properly...) |
||
Line 261: | Line 261: | ||
else begin |
else begin |
||
integer tPower, v, u; |
integer tPower, v, u; |
||
logical |
logical isContained; |
||
% find the lowest power of 10 that is greater then t % |
% find the lowest power of 10 that is greater then t % |
||
tPower := 10; |
tPower := 10; |
||
Line 269: | Line 269: | ||
v := v div 10 |
v := v div 10 |
||
end while_v_gt_9 ; |
end while_v_gt_9 ; |
||
isContained := false; |
|||
v := abs t; |
v := abs t; |
||
u := abs s; |
u := abs s; |
||
while not |
while not isContained and u > 0 do begin |
||
isContained := ( u rem tPower ) = v; |
|||
u := u div 10 |
u := u div 10 |
||
end |
end while_not_isContained_and_u_gt_0 ; |
||
isContained |
|||
end containsDigits ; |
end containsDigits ; |
||
% find and show the matching numbers up to 1000 % |
% find and show the matching numbers up to 1000 % |