Ask Your Question

Revision history [back]

Partial answer : for a single representation, you can use the sum_of_k_squares function :

sage: sum_of_k_squares(3, 12345678)
(63, 147, 3510)
sage: 63^2 + 147^2 + 3510^2
12345678

Finding all representations looks costly.

Partial answer : for a single representation, you can use the sum_of_k_squares function :

sage: sum_of_k_squares(3, 12345678)
(63, 147, 3510)
sage: 63^2 + 147^2 + 3510^2
12345678

Finding all representations looks costly.costly. Could you please provide an example of B and n you are willing to deal with ?