--- /dev/null
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "$f(n) = 1 + \\frac{1}{1 + f(n-1)}$\n",
+ "\n",
+ "$f(1) = \\frac{3}{2}$\n",
+ "\n",
+ "$f(2) = 1 + \\frac{1}{1 + f(1)} = 1 + \\frac{1}{1 + \\frac{3}{2}} = 1 + \\frac{1}{\\frac{5}{2}} = 1 + \\frac{2}{5} = \\frac{7}{5}$\n",
+ "\n",
+ "$f(3) = 1 + \\frac{1}{1 + f(2)} = 1 + \\frac{1}{1 + \\frac{7}{5}} = 1 + \\frac{1}{\\frac{12}{5}} = 1 + \\frac{5}{12} = \\frac{17}{12}$\n",
+ "\n",
+ "$f(n) = 1 + \\frac{1}{1 + \\frac{n}{d}} = 1 + \\frac{1}{\\frac{n+d}{d}} = 1 + \\frac{d}{n+d} = \\frac{n+2d}{n+d}$"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "153"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "count = 0\n",
+ "n, d = 3, 2\n",
+ "(1..1000).each do\n",
+ " # puts \"#{n}, #{d}, #{n.to_s.length > d.to_s.length}\"\n",
+ " count += 1 if n.to_s.length > d.to_s.length\n",
+ " n, d = n + 2 * d, n + d\n",
+ "end\n",
+ "count"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Ruby 2.4.0",
+ "language": "ruby",
+ "name": "ruby"
+ },
+ "language_info": {
+ "file_extension": ".rb",
+ "mimetype": "application/x-ruby",
+ "name": "ruby",
+ "version": "2.4.0"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}