Long multiplication: Difference between revisions
Content added Content deleted
MaiconSoft (talk | contribs) (Added Delphi example) |
(Updated to work with Nim 1.4: added parameter type, replaced "repeatChar" by "repeat", removed unused variables.) |
||
Line 3,808: | Line 3,808: | ||
<lang nim>import strutils |
<lang nim>import strutils |
||
proc ti(a): int = ord(a) - ord('0') |
proc ti(a: char): int = ord(a) - ord('0') |
||
proc longmulti(a, b: string): string = |
proc longmulti(a, b: string): string = |
||
var |
var |
||
i, j |
i, j = 0 |
||
k = false |
k = false |
||
Line 3,831: | Line 3,831: | ||
return |
return |
||
result = |
result = repeat('0', a.len + b.len) |
||
for i in countdown(a.high, 0): |
for i in countdown(a.high, 0): |