euler/ipython/EulerProblem048.ipynb

86 lines
1.7 KiB
Plaintext
Raw Normal View History

2018-12-23 01:36:44 +01:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Self powers (Euler Problem 48)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"[https://projecteuler.net/problem=48](https://projecteuler.net/problem=48)\n",
"\n",
"The series, $1^1 + 2^2 + 3^3 + ... + 10^{10} = 10405071317$.\n",
"\n",
"Find the last ten digits of the series, $1^1 + 2^2 + 3^3 + ... + 1000^{1000}$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Okay, this would be way harder in C/C++. In every language with long int support it is easy. See the number of people who have solved it."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"9110846700\n"
]
}
],
"source": [
"s = int(str(sum([i**i for i in range(1, 1001)]))[-10:])\n",
"assert(s == 9110846700)\n",
"print(s)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"completion_date": "Sun, 23 Dec 2018, 00:32",
"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": [
"brute force",
"self power"
]
},
"nbformat": 4,
"nbformat_minor": 2
}