{"record":{"id":"3f5d6e7a4f33e8dc","repo":"trekhleb/javascript-algorithms","slug":"can-t-handle-position-smaller-than-1-or-greater-th","errorCode":null,"errorMessage":"Can't handle position smaller than 1 or greater than ${topMaxValidPosition}","messagePattern":"Can't handle position smaller than 1 or greater than (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/algorithms/math/fibonacci/fibonacciNthClosedForm.js","lineNumber":13,"sourceCode":"export default function fibonacciClosedForm(position) {\n  const topMaxValidPosition = 70;\n\n  // Check that position is valid.\n  if (position < 1 || position > topMaxValidPosition) {\n    throw new Error(`Can't handle position smaller than 1 or greater than ${topMaxValidPosition}`);\n  }","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/trekhleb/javascript-algorithms/blob/85293e3e2b88f4d2ce330d956b139cf628aa1e82/src/algorithms/math/fibonacci/fibonacciNthClosedForm.js#L1-L24","documentation":"Error \"Can't handle position smaller than 1 or greater than ${topMaxValidPosition}\" thrown in trekhleb/javascript-algorithms.","triggerScenarios":"fibonacciClosedForm is called with a position below 1 (0 or negative) or above 70, outside the range where Binet's closed-form formula stays accurate.","commonSituations":"Requesting a Fibonacci number outside the safe range of Binet's formula; above 70 floating-point rounding makes the closed form inaccurate.","solutions":["Pass a position between 1 and 70 inclusive.","Validate the requested position against the 1..70 range before calling fibonacciClosedForm.","Use an iterative or BigInt-based fibonacci implementation for positions above 70, where the closed form loses precision."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"85293e3e2b88f4d2ce330d956b139cf628aa1e82","analyzedAt":"2026-08-24T05:59:10.417Z","schemaVersion":2},"datasetVersion":"2026-08-24T07:17:09.176Z"}