Distinct power numbers: Difference between revisions

Content added Content deleted
(add FreeBASIC)
(Added solution for Action!)
Line 7: Line 7:
<br>4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125
<br>4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125
<br><br>
<br><br>

=={{header|Action!}}==
{{libheader|Action! Tool Kit}}
<lang Action!>INCLUDE "D2:SORT.ACT" ;from the Action! Tool Kit

INT FUNC Power(INT a,b)
INT res,i

res=1
FOR i=1 TO b
DO
res==*a
OD
RETURN (res)

BYTE FUNC Contains(INT ARRAY a INT count,x)
INT i

FOR i=0 TO count-1
DO
IF a(i)=x THEN
RETURN (1)
FI
OD
RETURN (0)

PROC Main()
INT ARRAY a(100)
INT i,j,x,count

Put(125) PutE() ;clear the screen

count=0
FOR i=2 TO 5
DO
FOR j=2 TO 5
DO
x=Power(i,j)
IF Contains(a,count,x)=0 THEN
a(count)=x
count==+1
FI
OD
OD
SortI(a,count,0)
FOR i=0 TO count-1
DO
PrintI(a(i)) Put(32)
OD
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Distinct_power_numbers.png Screenshot from Atari 8-bit computer]
<pre>
4 8 9 16 25 27 32 64 81 125 243 256 625 1024 3125
</pre>


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==