Partition function P: Difference between revisions
Content added Content deleted
(→{{header|REXX}}: added a 3rd (faster) version.) |
m (→{{header|jq}}: indentation) |
||
Line 598: | Line 598: | ||
| (((.k * (3*.k - 1)) | div2) ) as $j |
| (((.k * (3*.k - 1)) | div2) ) as $j |
||
| if $j > $i then .stop=true |
| if $j > $i then .stop=true |
||
else if (.k % 2) == 1 |
else if (.k % 2) == 1 |
||
then .p[$i] = .p[$i] + .p[$i - $j] |
then .p[$i] = .p[$i] + .p[$i - $j] |
||
else .p[$i] = .p[$i] - .p[$i - $j] |
else .p[$i] = .p[$i] - .p[$i - $j] |
||
end |
end |
||
| (((.k * (3*.k + 1)) | div2)) as $j |
| (((.k * (3*.k + 1)) | div2)) as $j |
||
| if $j > $i then .stop=true |
| if $j > $i then .stop=true |
||
elif (.k % 2) == 1 |
elif (.k % 2) == 1 |