Z15076: Difference between revisions
Stevenliuyi (talk | contribs) No edit summary |
add memoization |
||
(3 intermediate revisions by one other user not shown) | |||
Line 11: | Line 11: | ||
"Z1K1": "Z16", |
"Z1K1": "Z16", |
||
"Z16K1": "Z610", |
"Z16K1": "Z610", |
||
"Z16K2": "def Z15075(Z15075K1):\n\tdef P(n):\n\t\tif n \ |
"Z16K2": "def Z15075(Z15075K1):\n\tknownValues = {}\n\tdef P(n):\n\t\tif n == 0:\n\t\t\treturn 1\n\t\telif n == 1 or n == 2:\n\t\t\treturn 0\n\t\telif n in knownValues:\n\t\t\treturn knownValues[n]\n\t\telse:\n\t\t\tresult = P(n-2)+P(n-3)\n\t\t\tknownValues[n] = result\n\t\t\treturn result\n\treturn P(Z15075K1)" |
||
} |
} |
||
}, |
}, |
||
Line 17: | Line 17: | ||
"Z1K1": "Z12", |
"Z1K1": "Z12", |
||
"Z12K1": [ |
"Z12K1": [ |
||
"Z11" |
"Z11", |
||
{ |
|||
"Z1K1": "Z11", |
|||
"Z11K1": "Z1002", |
|||
"Z11K2": "Padovan number, python (recursive relation)" |
|||
} |
|||
] |
] |
||
}, |
}, |
Latest revision as of 18:24, 11 April 2024
This page displays in a limited way without JavaScript.