2018-02-09 13:50:48 +01:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# Euler Problem 29\n",
|
|
|
|
"\n",
|
|
|
|
"Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:\n",
|
|
|
|
"\n",
|
|
|
|
"$2^2=4, 2^3=8, 2^4=16, 2^5=32$\n",
|
|
|
|
"\n",
|
2018-02-09 16:39:51 +01:00
|
|
|
"$3^2=9, 3^3=27, 3^4=81, 3^5=243$\n",
|
2018-02-09 13:50:48 +01:00
|
|
|
"\n",
|
2018-02-09 16:39:51 +01:00
|
|
|
"$4^2=16, 4^3=64, 4^4=256, 4^5=1024$\n",
|
2018-02-09 13:50:48 +01:00
|
|
|
"\n",
|
2018-02-09 16:39:51 +01:00
|
|
|
"$5^2=25, 5^3=125, 5^4=625, 5^5=3125$\n",
|
2018-02-09 13:50:48 +01:00
|
|
|
"\n",
|
|
|
|
"If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct terms:\n",
|
|
|
|
"\n",
|
2018-02-09 16:39:51 +01:00
|
|
|
"$4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125$\n",
|
2018-02-09 13:50:48 +01:00
|
|
|
"\n",
|
2018-02-09 16:39:51 +01:00
|
|
|
"How many distinct terms are in the sequence generated by $a^b$ for $2 ≤ a ≤ 100$ and $2 ≤ b ≤ 100$?"
|
2018-02-09 13:50:48 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2018-02-09 16:39:51 +01:00
|
|
|
"execution_count": 1,
|
2018-02-10 10:50:52 +01:00
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
2018-02-09 16:39:51 +01:00
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"9183\n"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"s = len(set([a**b for a in range(2, 101) for b in range(2, 101)]))\n",
|
|
|
|
"assert(s == 9183)\n",
|
|
|
|
"print(s)"
|
|
|
|
]
|
2018-02-09 13:50:48 +01:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
2018-02-10 10:50:52 +01:00
|
|
|
"completion_date": "Fri, 25 Aug 2017, 10:03",
|
2018-02-09 13:50:48 +01:00
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "Python 3",
|
|
|
|
"language": "python",
|
|
|
|
"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",
|
2018-02-10 10:50:52 +01:00
|
|
|
"version": "3.5.4"
|
2018-02-09 13:50:48 +01:00
|
|
|
},
|
2018-02-09 16:39:51 +01:00
|
|
|
"tags": [
|
|
|
|
"distinct",
|
|
|
|
"powers"
|
|
|
|
]
|
2018-02-09 13:50:48 +01:00
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 2
|
|
|
|
}
|