Hi everyone,(adsbygoogle = window.adsbygoogle || []).push({});

I am trying to define a functionpartitionin Haskell that takes in an integer as an argument and returns a list of all possible positive integers that would sum to the input, ie

partition 4 = [[1, 1, 1, 1], [1, 1, 2], [1, 3], [2, 2], [4]]

The function (formally defined) can be found here

http://en.wikipedia.org/wiki/Partition_function_(number_theory)

From the outset it looks like i'll need to increment and decrement different variables on each recursive call, but have no idea where to start. Sorry if this seems trivial, but i think it's rather difficult for a beginners tutorial :)

Thanks for your help

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Partition Function

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads for Partition Function | Date |
---|---|

Why do the conjugate classes of a group partition the group? | Jan 21, 2015 |

Cosets / Partitions | Dec 17, 2014 |

Partitioning a Group Into Disjoint Subgroups | Aug 29, 2014 |

Sum_{k=0n} p(k) where p(k) = number of partitions of k | Nov 5, 2012 |

OBSERVATION: The #31, The Golden Scale, Prime Counting Function & Partition Numbers | Feb 4, 2011 |

**Physics Forums - The Fusion of Science and Community**