Distinct power numbers: Difference between revisions
Content added Content deleted
No edit summary |
(Added Wren) |
||
Line 52: | Line 52: | ||
Found 15 numbers |
Found 15 numbers |
||
done... |
done... |
||
</pre> |
|||
=={{header|Wren}}== |
|||
{{libheader|Wren-seq}} |
|||
{{libheader|Wren-fmt}} |
|||
<lang ecmascript>import "/seq" for Lst |
|||
import "/fmt" for Fmt |
|||
var pows = [] |
|||
for (a in 2..5) { |
|||
var pow = a |
|||
for (b in 2..5) { |
|||
pow = pow * a |
|||
pows.add(pow) |
|||
} |
|||
} |
|||
pows = Lst.distinct(pows).sort() |
|||
System.print("Ordered distinct values of a ^ b for a in [2..5] and b in [2..5]:") |
|||
for (chunk in Lst.chunks(pows, 5)) Fmt.print("$,5d", chunk) |
|||
System.print("\nFound %(pows.count) such numbers.")</lang> |
|||
{{out}} |
|||
<pre> |
|||
Ordered distinct values of a ^ b for a in [2..5] and b in [2..5]: |
|||
4 8 9 16 25 |
|||
27 32 64 81 125 |
|||
243 256 625 1,024 3,125 |
|||
Found 15 such numbers. |
|||
</pre> |
</pre> |