move notebooks to subdir
This commit is contained in:
68
notebooks/problem0016.ipynb
Normal file
68
notebooks/problem0016.ipynb
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "78b44de2",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# [Power Digit Sum](https://projecteuler.net/problem=16)\n",
|
||||
"\n",
|
||||
"Since Python/SageMath support integers of arbitrary size, this problem is pretty straightforward. Just compute $2^{1000}$ directly and sum the digits up."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "d3a790fe",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1366\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"n = 2 ^ 1000\n",
|
||||
"total = 0\n",
|
||||
"while n != 0:\n",
|
||||
" total += n % 10\n",
|
||||
" n //= 10\n",
|
||||
"\n",
|
||||
"print(total)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "60ba69ac",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Relevant sequences\n",
|
||||
"* Sums of digits of $2^n$: [A001370](https://oeis.org/A001370)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "SageMath 9.5",
|
||||
"language": "sage",
|
||||
"name": "sagemath"
|
||||
},
|
||||
"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.11.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user