diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-08-17 20:39:03 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-08-17 20:39:03 +0200 |
| commit | 9a65938232d1fa9e1afe9a6eb2de48d25ff738a6 (patch) | |
| tree | 6f5e9dbef23a884a74f9fa10643ff5c0bea3d751 /haskell/029-distinct_powers.hs | |
| parent | 78fbf8dbcf39aa51cf682a8795d0d0c3be6034c6 (diff) | |
| download | project_euler-9a65938232d1fa9e1afe9a6eb2de48d25ff738a6.tar.gz project_euler-9a65938232d1fa9e1afe9a6eb2de48d25ff738a6.tar.bz2 project_euler-9a65938232d1fa9e1afe9a6eb2de48d25ff738a6.zip | |
haskell problem 22, 24, 25, 29, 39, 40, 45, 53, 59
Diffstat (limited to 'haskell/029-distinct_powers.hs')
| -rw-r--r-- | haskell/029-distinct_powers.hs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/haskell/029-distinct_powers.hs b/haskell/029-distinct_powers.hs new file mode 100644 index 0000000..132ffe0 --- /dev/null +++ b/haskell/029-distinct_powers.hs @@ -0,0 +1,17 @@ +-- Consider all integer combinations of a^b for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: +-- +-- 2^2=4, 2^3=8, 2^4=16, 2^5=32 +-- 3^2=9, 3^3=27, 3^4=81, 3^5=243 +-- 4^2=16, 4^3=64, 4^4=256, 4^5=1024 +-- 5^2=25, 5^3=125, 5^4=625, 5^5=3125 +-- If they are then placed 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 +-- +-- How many distinct terms are in the sequence generated by ab for 2 ≤ a ≤ 100 and 2 ≤ b ≤ 100? + + +import Data.List (nub) + +main = print (length $ nub [a ^ b | a <- [2..100], b <- [2..100]]) |
