Jump to content

Distinct power numbers: Difference between revisions

→‎{{header|Haskell}}: Added a variant
(Added Algol 68)
(→‎{{header|Haskell}}: Added a variant)
Line 365:
print $
distinctPowerNumbers 2 5</lang>
{{Out}}
<pre>[4,8,9,16,25,27,32,64,81,125,243,256,625,1024,3125]</pre>
 
 
or, as a one-off list comprehension:
 
<lang haskell>import qualified Data.Set as S
 
main :: IO ()
main =
(print . S.elems . S.fromList) $
(\xs -> [x ^ y | x <- xs, y <- xs]) [2 .. 5]</lang>
{{Out}}
<pre>[4,8,9,16,25,27,32,64,81,125,243,256,625,1024,3125]</pre>
9,655

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.