Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Created September 20, 2016 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/608449bad858363c483c6750bd2dd773 to your computer and use it in GitHub Desktop.
Save kurozumi/608449bad858363c483c6750bd2dd773 to your computer and use it in GitHub Desktop.
【Python】Sympyを使って素因数分解をする方法
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# sympyをインポート\n",
"import sympy"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{2: 5, 3: 2, 7: 1}"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 2016を素因数分解して辞書にする\n",
"sympy.factorint(2016)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$ 2016=2^5\\times3^2\\times7^1 $"
]
}
],
"metadata": {
"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",
"version": "3.5.1"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment