Skip to content

Instantly share code, notes, and snippets.

@barisaltunkara
Created May 10, 2021 14:24
Show Gist options
  • Save barisaltunkara/3d35e92fe6dea1b393939c6eb00434ca to your computer and use it in GitHub Desktop.
Save barisaltunkara/3d35e92fe6dea1b393939c6eb00434ca to your computer and use it in GitHub Desktop.
PycharmProjects/Untitled.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "def mortalfiborabbit(n, m):\n a = 1\n c = [0]\n for i in range(1,n):\n if i > m:\n c.append(int(a - 1))\n a += c[i-1] - c[i-m]\n else:\n c.append(a)\n a += c[i-1]\n \n return c[1:]",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "print(mortalfiborabbit(100,16))",
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"text": "[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1596, 2582, 4177, 6757, 10931, 17683, 28606, 46276, 74861, 121103, 195909, 316923, 512688, 829378, 1341689, 2170457, 3511159, 5680020, 9188597, 14864440, 24046280, 38899789, 62928386, 101799569, 164681679, 266406387, 430966963, 697177441, 1127827481, 1824492234, 2951490337, 4774640882, 7723960762, 12495090485, 20213371227, 32699273115, 52897779902, 85573006737, 138431886850, 223941965201, 362272052482, 586049336004, 948054982099, 1533673351140, 2481031155798, 4013576679457, 6492783343021, 10503408532141, 16991417234280, 27487101805659, 44466023949454, 71932912383886, 116366237060225, 188246251664209, 304526915717697, 492634735495056, 796937709247552, 1289210172690126, 2085561832601674, 3373823950309701, 5457852109560235, 8829195028714138, 14283033561594916, 23105735806966033, 37378265960028808, 60467010349760561, 97817789207983710, 158240333533794817, 255986189829394641, 414110157126129233, 669908100703859665, 1083713730914271201, 1753129196882635810, 2836045990087659459, 4587885976797605143, 7421846405052662928, 12006358557899958370, 19422747110843061063, 31420276473714305295, 50828740550995771442, 82225911288903110704, 133017273573938853338, 215182717852492203481]\n",
"name": "stdout"
}
]
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.8.5",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "PycharmProjects/Untitled.ipynb",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment