Post Reply 
(38G) Integer Partitions (Using Ramanujam's Method)
04-01-2015, 01:12 PM (This post was last modified: 06-15-2017 01:57 PM by Gene.)
Post: #1
(38G) Integer Partitions (Using Ramanujam's Method)
For input N a positive integer the programme returns the number of integer partitions in Ans & displays the result.

Faster than Gauss' method but subject to inaccuracies for higher values of N.

Improvements welcome.

INT(Ans)►N:
IF N<1
THEN
0:
ELSE
0►B:
√(2/3)►H:
1►C:
N-1/24►F:
√F►R:
R*H*π►G:
π*H/F►H:
F*R►F:
2*π►P:
2*N►Q:
DO
0►E:
FOR D=1 TO C STEP 1;
C►I:
D►J:
DO
I MOD J►K:
J►I:
K►J:
UNTIL
K==0
END:
IF I==1
THEN
COS(π*( Σ(I=1,C-1,(FRAC((D*I)/C)-.5)*(I/C-.5))+.25-(Q*D)/C))+E►E:
END:
END:
G/C:
(COSH(Ans)*H/C-SINH(Ans)/F)*√C/P►O:
C+1►C:
O*E+B►B:
UNTIL
ROUND(O+B,0)==ROUND(B,0)
END:
ROUND(B,0)►B:
END:
ERASE:
DISP 2;" p("N")":
DISP 4;" "B:
FREEZE:
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)