Files
euler/ipython/EulerProblem057.ipynb

71 lines
1.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Square root convergents (Euler Problem 57)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"[https://projecteuler.net/problem=57](https://projecteuler.net/problem=57)\n",
"\n",
"It is possible to show that the square root of two can be expressed as an infinite continued fraction.\n",
"\n",
"√ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213...\n",
"\n",
"By expanding this for the first four iterations, we get:\n",
"\n",
"1 + 1/2 = 3/2 = 1.5\n",
"\n",
"1 + 1/(2 + 1/2) = 7/5 = 1.4\n",
"\n",
"1 + 1/(2 + 1/(2 + 1/2)) = 17/12 = 1.41666...\n",
"\n",
"1 + 1/(2 + 1/(2 + 1/(2 + 1/2))) = 41/29 = 1.41379...\n",
"\n",
"The next three expansions are 99/70, 239/169, and 577/408, but the eighth expansion, 1393/985, is the first example where the number of digits in the numerator exceeds the number of digits in the denominator.\n",
"\n",
"In the first one-thousand expansions, how many fractions contain a numerator with more digits than denominator?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"completion_date": "",
"kernelspec": {
"display_name": "Python 3",
"language": "python3.6",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
},
"tags": []
},
"nbformat": 4,
"nbformat_minor": 2
}