{ "metadata": { "name": "", "signature": "sha256:0436e72f1d4aba99574ecd8525b1de6b98fb1fd8eb76582449c2750dede80702" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "import time\n", "\n", "start = time.time()\n", "Fn_1 = 1\n", "Fn = 2\n", "fib_sum = 0\n", "while(Fn < 4e6):\n", " if Fn%2==0:\n", " fib_sum += Fn\n", " Fn, Fn_1 = Fn+Fn_1, Fn \n", "\n", "print \"Answer:{}\".format( fib_sum )\n", "print \"Elapsed time:{0} seconds\".format(time.time()-start)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Answer:4613732\n", "Elapsed time:0.000380992889404 seconds\n" ] } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }