Jump to content

Pythagorean quadruples: Difference between revisions

m
→‎{{header|Sidef}}: updated code -- sqrtmod(a,m) is now built-in
m (→‎{{header|REXX}}: elided a no longer relevant comment.)
m (→‎{{header|Sidef}}: updated code -- sqrtmod(a,m) is now built-in)
Line 1,906:
 
=={{header|Sidef}}==
<lang ruby># Finds all solutions (a,b) such that: a^2 + b^2 = n^2
<lang ruby>require('ntheory')
 
# Finds all solutions (a,b) such that: a^2 + b^2 = n^2
func sum_of_two_squares(n) is cached {
 
Line 1,947 ⟶ 1,945:
for p,e in (prime_powers) {
var pp = p**e
var r = %S<ntheory>.sqrtmod("#{pp - 1}", "#{pp}")
take([[r, pp], [pp - r, pp]])
}
2,747

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.