American Citizen on Sat, 18 Nov 2023 02:12:00 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

question on finding exhaustive search algorithm for a^2+b^2 = N


Thank you all for being patient with me.

I wrote an algorithm to find two squares summing to N

sol2(N) = Set(abs(vecsort(qfbsolve(Qfb(1,0,1),N,3),,4)))

Running this for n = 5*13*17*29*37 gives

sol2(1185665) = [[601, 908], [607, 904], [664, 863], [673, 856], [743, 796], [796, 743], [856, 673], [863, 664], [904, 607], [908, 601], [929, 568], [961, 512], [992, 449], [1028, 359], [1049, 292], [1052, 281], [1063, 236], [1072, 191], [1076, 167], [1084, 103], [1087, 64]]

which is 21 solutions.

Carefully writing a program which exhaustively searches comes up with the following 32 solutions:

[[64, 1087], [103, 1084], [167, 1076], [191, 1072], [236, 1063], [281, 1052], [292, 1049], [359, 1028], [449, 992], [512, 961], [568, 929], [601, 908], [607, 904], [664, 863], [673, 856], [743, 796], [796, 743], [856, 673], [863, 664], [904, 607], [908, 601], [929, 568], [961, 512], [992, 449], [1028, 359], [1049, 292], [1052, 281], [1063, 236], [1072, 191], [1076, 167], [1084, 103], [1087, 64]]

Where did the missing 11 solutions go?

My goal is an exhaustive search of 2 squares = N algorithm

Randall