Distinct power numbers: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
;Task: |
;Task: |
||
Let given all integer combinations of |
Let given all integer combinations of <math>a^b</math> for '''2 < a < 5''' and '''2 < b < 5''': |
||
<br> |
<br> |
||
<math>2^2=4 ,2^3=8, 2^4=16, 2^5=32</math> |
<math>2^2=4 ,2^3=8, 2^4=16, 2^5=32</math> |
Revision as of 04:24, 16 August 2021
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 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...