Partition an integer x into n primes: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: (minor reductions – fractionally faster)) |
|||
Line 613: | Line 613: | ||
-------------------- PRIME PARTITIONS --------------------- |
-------------------- PRIME PARTITIONS --------------------- |
||
partitions :: Int -> Int -> [Int] |
|||
partitions x n |
|||
| n <= 1 = |
| n <= 1 = |
||
[ x |
[ x |
||
Line 638: | Line 638: | ||
" -> " |
" -> " |
||
[ justifyLeft 9 ' ' (show (x, n)) |
[ justifyLeft 9 ' ' (show (x, n)) |
||
, let xs = |
, let xs = partitions x n |
||
in bool (intercalate "+" (show <$> xs)) "(no solution)" (null xs) |
in bool (intercalate "+" (show <$> xs)) "(no solution)" (null xs) |
||
]) <$> |
]) <$> |