Distinct power numbers

Revision as of 04:20, 16 August 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task: Let given all integer combinations of ab for '''2 < a < 5''' and '''2 < b < 5''': <br> <math>2^2=4,2^3=8,2^4=16,2^5=32</math> <br> <math>3^2=9,3^3=27,3^...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

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

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...