Last active
January 3, 2016 20:09
-
-
Save pybokeh/8513531 to your computer and use it in GitHub Desktop.
Project_Euler_1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.\n", | |
"\n", | |
"Find the sum of all the multiples of 3 or 5 below 1000." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"multiplesof3_or_5 = []\n", | |
"sum_numbers = 0\n", | |
"for num in range(1,1000):\n", | |
" if num%3==0 or num%5==0:\n", | |
" sum_numbers = sum_numbers + num\n", | |
"\n", | |
"sum_numbers = 0\n", | |
"for number in multiplesof3_or_5:\n", | |
" sum_numbers = sum_numbers + number\n", | |
"\n", | |
"print(sum_numbers)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"233168\n" | |
] | |
} | |
], | |
"prompt_number": 79 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"sum(multiplesof3_or_5)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 81, | |
"text": [ | |
"233168" | |
] | |
} | |
], | |
"prompt_number": 81 | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment