Product of divisors: Difference between revisions
Content added Content deleted
Line 824: | Line 824: | ||
41 3111696 43 85184 91125 |
41 3111696 43 85184 91125 |
||
2116 47 254803968 343 125000</pre> |
2116 47 254803968 343 125000</pre> |
||
=={{header|Nim}}== |
|||
<lang Nim>import math, strutils |
|||
func divisors(n: Positive): seq[int] = |
|||
result = @[1, n] |
|||
for i in 2..sqrt(n.toFloat).int: |
|||
if n mod i == 0: |
|||
let j = n div i |
|||
result.add i |
|||
if i != j: result.add j |
|||
echo "Product of divisors for the first 50 positive numbers:" |
|||
for n in 1..50: |
|||
stdout.write ($prod(n.divisors)).align(10), if n mod 5 == 0: '\n' else: ' '</lang> |
|||
{{out}} |
|||
<pre>Product of divisors for the first 50 positive numbers: |
|||
1 2 3 8 5 |
|||
36 7 64 27 100 |
|||
11 1728 13 196 225 |
|||
1024 17 5832 19 8000 |
|||
441 484 23 331776 125 |
|||
676 729 21952 29 810000 |
|||
31 32768 1089 1156 1225 |
|||
10077696 37 1444 1521 2560000 |
|||
41 3111696 43 85184 91125 |
|||
2116 47 254803968 343 125000</pre> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |