Sha256: d683d5e2847af5d24aefb7ef125a0b9f55cec0ecf14e9be1a6107089a9ab82c1
Contents?: true
Size: 533 Bytes
Versions: 238
Compression:
Stored size: 533 Bytes
Contents
package pythagorean type Triplet [3]int func pyth(a, b, c int) bool { return a*a+b*b == c*c } func Range(min, max int) (ts []Triplet) { for a := min; a <= max; a++ { for b := a; b <= max; b++ { for c := b; c <= max; c++ { if pyth(a, b, c) { ts = append(ts, Triplet{a, b, c}) } } } } return } func Sum(sum int) (ts []Triplet) { max := sum / 2 for a := 1; a <= max; a++ { for b := a; b <= max; b++ { if c := sum - a - b; pyth(a, b, c) { ts = append(ts, Triplet{a, b, c}) } } } return }
Version data entries
238 entries across 238 versions & 1 rubygems