・パイソニスタの方へ
四平方数で、できませんでした。ページ後半です。
アドバイスをお願いします。
オリジナル
PASSLABO 様 (0:00〜10:24)
オリジナル様の方法で
・勉強中? 私はあきらめました。
pythonで
・(ページ後半の)ChatGPT先生のコードを修正しました。
・計算結果込みの方法で、できませんでした。
・順列→組み合わせ 変換のおすすめの方法を教えて下さい。
・??? 207通り(207行あります。) ???
import math
def find_natural_numbers(sum_of_squares):
solutions = []
max_value = int(math.sqrt(sum_of_squares)) + 1
ic=0
for a in range(1, max_value):
for b in range(a, max_value):
for c in range(b, max_value):
for d in range(c, max_value):
if a**2 + b**2 + c**2 + d**2 == sum_of_squares:
ic=ic+1
print("#",ic,a, b, c, d)
return solutions
# 7225を与えて、条件を満たす組み合わせを探す
solutions = find_natural_numbers(7225)
# 1 1 2 38 76
# 2 1 4 22 82
# 3 1 4 58 62
# 4 1 10 20 82
# 5 1 10 50 68
# 6 1 22 46 68
# 7 1 26 52 62
# 8 1 34 38 68
# 9 1 34 52 58
# 10 1 38 44 62
# 11 2 8 41 74
# 12 2 8 46 71
# 13 2 10 55 64
# 14 2 14 25 80
# 15 2 14 28 79
# 16 2 14 49 68
# 17 2 17 34 76
# 18 2 22 31 76
# 19 2 25 50 64
# 20 2 28 31 74
# 21 2 32 34 71
# 22 2 38 41 64
# 23 2 46 49 52
# 24 3 4 12 84
# 25 3 4 60 60
# 26 3 12 36 76
# 27 3 36 36 68
# 28 4 4 52 67
# 29 4 5 28 80
# 30 4 6 33 78
# 31 4 8 16 83
# 32 4 8 37 76
# 33 4 10 47 70
# 34 4 12 48 69
# 35 4 14 17 82
# 36 4 15 30 78
# 37 4 16 32 77
# 38 4 17 38 74
# 39 4 18 18 81
# 40 4 18 54 63
# 41 4 22 22 79
# 42 4 22 50 65
# 43 4 27 36 72
# 44 4 28 44 67
# 45 4 28 52 61
# 46 4 32 52 59
# 47 4 33 42 66
# 48 4 34 47 62
# 49 4 37 52 56
# 50 4 38 49 58
# 51 4 47 50 50
# 52 4 48 48 51
# 53 5 20 20 80
# 54 5 20 32 76
# 55 5 20 52 64
# 56 5 36 48 60
# 57 6 9 32 78
# 58 6 12 22 81
# 59 6 12 31 78
# 60 6 15 58 60
# 61 6 18 33 76
# 62 6 18 41 72
# 63 6 22 39 72
# 64 6 23 24 78
# 65 6 23 48 66
# 66 6 24 57 58
# 67 6 32 54 57
# 68 6 33 50 60
# 69 6 39 48 58
# 70 7 10 26 80
# 71 7 10 40 74
# 72 7 14 16 82
# 73 7 14 56 62
# 74 7 16 38 74
# 75 7 26 32 74
# 76 7 26 40 70
# 77 7 26 56 58
# 78 8 16 53 64
# 79 8 19 20 80
# 80 8 19 32 76
# 81 8 19 52 64
# 82 8 23 34 74
# 83 8 26 34 73
# 84 8 26 38 71
# 85 8 41 46 58
# 86 9 14 42 72
# 87 9 22 24 78
# 88 9 22 48 66
# 89 9 32 42 66
# 90 10 10 25 80
# 91 10 10 28 79
# 92 10 10 49 68
# 93 10 14 23 80
# 94 10 14 40 73
# 95 10 14 52 65
# 96 10 16 55 62
# 97 10 17 44 70
# 98 10 20 22 79
# 99 10 20 50 65
# 100 10 22 40 71
# 101 10 23 50 64
# 102 10 25 32 74
# 103 10 25 40 70
# 104 10 25 56 58
# 105 10 28 46 65
# 106 10 40 41 62
# 107 10 40 50 55
# 108 12 14 18 81
# 109 12 14 54 63
# 110 12 15 50 66
# 111 12 18 49 66
# 112 12 24 24 77
# 113 12 24 27 76
# 114 12 31 42 66
# 115 12 32 36 69
# 116 12 36 36 67
# 117 12 36 48 59
# 118 12 42 49 54
# 119 13 16 20 80
# 120 13 16 32 76
# 121 13 16 52 64
# 122 13 24 36 72
# 123 13 28 56 56
# 124 13 32 44 64
# 125 14 14 47 68
# 126 14 16 38 73
# 127 14 17 46 68
# 128 14 18 39 72
# 129 14 23 32 74
# 130 14 23 40 70
# 131 14 23 56 58
# 132 14 26 32 73
# 133 14 28 49 62
# 134 14 31 38 68
# 135 14 31 52 58
# 136 14 36 42 63
# 137 14 46 47 52
# 138 15 18 30 76
# 139 15 22 54 60
# 140 15 30 50 60
# 141 16 16 28 77
# 142 16 22 34 73
# 143 16 22 38 71
# 144 16 25 38 70
# 145 16 25 50 62
# 146 16 28 52 59
# 147 16 32 43 64
# 148 16 32 53 56
# 149 16 38 41 62
# 150 16 38 50 55
# 151 17 22 26 76
# 152 17 26 28 74
# 153 17 34 34 68
# 154 17 34 44 62
# 155 17 44 50 50
# 156 17 46 46 52
# 157 18 30 49 60
# 158 18 32 39 66
# 159 18 41 48 54
# 160 19 32 52 56
# 161 20 20 44 67
# 162 20 20 52 61
# 163 20 22 46 65
# 164 20 31 50 58
# 165 20 34 38 65
# 166 20 46 47 50
# 167 21 24 32 72
# 168 22 23 46 64
# 169 22 24 54 57
# 170 22 26 32 71
# 171 22 31 34 68
# 172 22 31 44 62
# 173 22 33 36 66
# 174 22 39 48 54
# 175 22 40 46 55
# 176 23 24 42 66
# 177 23 34 38 64
# 178 23 38 46 56
# 179 24 27 36 68
# 180 24 30 50 57
# 181 24 32 45 60
# 182 24 39 42 58
# 183 25 26 32 70
# 184 25 34 40 62
# 185 25 40 50 50
# 186 26 28 49 58
# 187 26 32 41 62
# 188 26 32 50 55
# 189 26 38 49 52
# 190 27 36 40 60
# 191 28 28 44 61
# 192 28 31 46 58
# 193 28 32 44 59
# 194 28 37 44 56
# 195 28 46 46 47
# 196 30 31 42 60
# 197 30 39 48 50
# 198 31 38 46 52
# 199 32 34 41 58
# 200 32 36 48 51
# 201 32 39 42 54
# 202 34 34 47 52
# 203 34 38 40 55
# 204 36 40 45 48
# 205 36 42 42 49
# 206 38 38 44 49
# 207 38 40 41 50
WolframAlphaで
・(勉強中?)教えて下さい。
途中:勉強中
四平方数で、できませんでした。
wipideia
https://en.wikipedia.org/wiki/Jacobi%27s_four-square_theorem
https://ja.wikipedia.org/wiki/ヤコビの四平方定理
△ ChatGPTで 7225 四平方数
? ChatGPTで 7225 自然数の四平方数 うまくいきませんでした。
? googleで 7225 四平方数
✕ wolframalphaで 7225 四平方数
# 当初
# import math
# def find_natural_numbers(sum_of_squares):
# solutions = []
# max_value = int(math.sqrt(sum_of_squares)) + 1
# for a in range(1, max_value):
# for b in range(a, max_value):
# for c in range(b, max_value):
# for d in range(c, max_value):
# if a**2 + b**2 + c**2 + d**2 == sum_of_squares:
# solutions.append((a, b, c, d))
# return solutions
# # 7225を与えて、条件を満たす組み合わせを探す
# solutions = find_natural_numbers(7225)
# for solution in solutions:
# print(solution)
いつもの? sympyの実行環境と 参考のおすすめです。
いつもと違うおすすめです。
・