add problem 52
This commit is contained in:
parent
102e00008a
commit
2ea7b7ceaa
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7e6181f8",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# [Permuted Multiples](https://projecteuler.net/problem=52)\n",
|
||||
"\n",
|
||||
"There's a chance you think of 1/7 when you read this problem and immediately find the answer. But if not, it doesn't take long for the computer to tell you."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "10854a24",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"142857"
|
||||
]
|
||||
},
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from itertools import count\n",
|
||||
"\n",
|
||||
"for n in count(1):\n",
|
||||
" digits = set(str(n))\n",
|
||||
" for x in (2, 3, 4, 5, 6):\n",
|
||||
" if set(str(n*x)) != digits:\n",
|
||||
" break\n",
|
||||
" else:\n",
|
||||
" break\n",
|
||||
" \n",
|
||||
"n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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
|
||||
}
|
Loading…
Reference in New Issue