Distinct power numbers
Appearance
Distinct power numbers is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
- Task
Let given all integer combinations of ab for 2 < a < 5 and 2 < b < 5:
Place them in numerical order, with any repeats removed.
We get the following sequence of 15 distinct terms:
4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125
Ring
<lang ring> load "stdlib.ring"
see "working..." + nl see "Distinct powers are:" + nl row = 0 distPow = []
for n = 2 to 5
for m = 2 to 5 sum = pow(n,m) add(distPow,sum) next
next
distPow = sort(distPow)
for n = len(distPow) to 2 step -1
if distPow[n] = distPow[n-1] del(distPow,n-1) ok
next
for n = 1 to len(distPow)
row++ see "" + distPow[n] + " " if row%5 = 0 see nl ok
next
see "Found " + row + " numbers" + nl see "done..." + nl </lang>
- Output:
working... Distinct powers are: 4 8 9 16 25 27 32 64 81 125 243 256 625 1024 3125 Found 15 numbers done...