Skip to content

Instantly share code, notes, and snippets.

@foxqstm
Created September 2, 2019 05:11
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 foxqstm/1f305e2c5abc78b7f3fda7ca37aeab46 to your computer and use it in GitHub Desktop.
Save foxqstm/1f305e2c5abc78b7f3fda7ca37aeab46 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[9, 40] [[0, 0], [1, 1], [1, 3], [2, 1], [2, 2]] 4\n",
"100\n",
"200\n",
"300\n",
"400\n",
"500\n",
"600\n",
"700\n",
"800\n",
"900\n",
"1000\n",
"1100\n",
"1200\n",
"1300\n",
"1400\n",
"1500\n",
"1600\n",
"1700\n",
"1800\n",
"1900\n",
"2000\n",
"2100\n",
"2200\n",
"2300\n",
"2400\n",
"2500\n",
"2600\n",
"2700\n",
"2800\n",
"2900\n",
"3000\n",
"3100\n",
"3200\n",
"3300\n",
"3400\n",
"3500\n",
"3600\n",
"3700\n",
"3800\n",
"3900\n",
"4000\n",
"4100\n",
"4200\n",
"4300\n",
"4400\n",
"4500\n",
"4600\n",
"4700\n",
"4800\n",
"4900\n",
"5000\n",
"5100\n",
"5200\n",
"5300\n",
"5400\n",
"5500\n",
"5600\n",
"5700\n",
"5800\n",
"5900\n",
"6000\n",
"6100\n",
"6200\n",
"6300\n",
"6400\n",
"6500\n",
"6600\n",
"6700\n",
"6800\n",
"6900\n",
"7000\n",
"7100\n",
"7200\n",
"7300\n",
"7400\n",
"7500\n",
"7600\n",
"7700\n",
"7800\n",
"7900\n",
"8000\n",
"8100\n",
"8200\n",
"8300\n",
"8400\n",
"8500\n",
"8600\n",
"8700\n",
"8800\n",
"8900\n",
"9000\n",
"9100\n",
"9200\n",
"9300\n",
"9400\n",
"9500\n",
"9600\n",
"9700\n",
"9800\n",
"9900\n",
"10000\n",
"[[0, 0], [9, 40]]\n"
]
}
],
"source": [
"import math\n",
"import numpy as np\n",
"\n",
"n=10\n",
"N=10000\n",
"A_B=[[0,0]]\n",
"A=3\n",
"B=4\n",
"cnt2=0\n",
"\n",
"for s in range(1,N+1):\n",
" if(s%100==0):\n",
" print(s)\n",
" for t in range (1,s+1):\n",
" if (((s+t)%2)==0):\n",
" continue\n",
" if (math.gcd(s,t))!=1:\n",
" continue\n",
" A=s**2-t**2\n",
" B=2*s*t\n",
"\n",
" a_b=[[0,0]]\n",
" cnt=0\n",
" for i in range(1,n+1):\n",
" for j in range (1,n+1):\n",
" Ap=A**i\n",
" Bp=B**j\n",
" ApBp=Ap+Bp\n",
" sqApBp=math.sqrt(ApBp)\n",
" Rootc=math.ceil(sqApBp)\n",
" Rootf=math.floor(sqApBp)\n",
" if (ApBp==Rootc**2) or (ApBp==Rootf**2):\n",
" a_b.append([i,j])\n",
" cnt+=1\n",
"\n",
" if(len(a_b)>=4):\n",
" cnt2+=1\n",
" A_B.append([A,B])\n",
" print(A_B[cnt2],a_b,len(a_b)-1)\n",
"print(A_B)"
]
}
],
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment