10-08-2016, 07:07 AM
Enter positive integer N in the HOME screen then activate programme P5 - the number of integer partitions of N is returned in Ans in the HOME screen.
For info on partitions see
http://mathworld.wolfram.com/Partition.html
For info on partitions see
http://mathworld.wolfram.com/Partition.html
Code:
P5
INT(Ans)►N:
IF N<1
THEN
0:
ELSE
0►B:
√(2/3)►H:
1►C:
N-1/24►F:
√F►R:
RHπ►G:
πH/F►H:
FR►F:
2π►P:
2N►Q:
DO
0:
FOR D=1 TO C STEP 1;
IF GCD(C,D)==1 #For 39gs/G & 38G replace this line with snippet below this programme.
THEN
COS(π*(Σ(I=1,C-1,
(FRAC(DI/C)-.5)*(I/C-.5))+.25-QD/C))+Ans:
END:
END:
Ans►E:
G/C:
(COSH(Ans)H/C-SINH(Ans)/F)√C/P►O:
C+1►C:
OE+B►B:
ROUND(O+B,0):
UNTIL
Ans==ROUND(B,0)
END:
END:
ERASE:
Replacement snippet for 39G/gs & 38G
C►I:
D►J:
DO
I MOD J►K:
J►I:
K►J:
UNTIL
NOT K
END:
IF I==1