Number of Partitions

  • MATLAB
  • Thread starter richieec
  • Start date
  • #1
2
0
This program have to calculate the numbers of partitions of a number using the euler formula
So, here is the program i have done, i don't know where is the mistakes, and I would greatly appreciate to help me.
http://mathworld.wolfram.com/PartitionFunctionP.html#eqn11

Code:
function fn = euler(n)

if n == 0
    fn = 1;
    return
else
    for i = 1 : 1 : n
    fn = ((-1)^ (i + 1)) * euler(n - i * (3 * i - 1) / 2 ) + euler(n - i * (3 * i + 1 ) / 2);
    return
     end
  end
end
 
Last edited by a moderator:

Answers and Replies

Related Threads on Number of Partitions

Replies
0
Views
814
Replies
1
Views
3K
  • Last Post
Replies
4
Views
16K
Replies
1
Views
1K
  • Last Post
Replies
3
Views
710
Replies
0
Views
851
Top