add new solutions
This commit is contained in:
parent
ca24d0a56a
commit
0c73608ce5
36 changed files with 791 additions and 0 deletions
25
solutions/19/q1925/solution.go
Normal file
25
solutions/19/q1925/solution.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package q1925
|
||||
|
||||
import "math"
|
||||
|
||||
func countTriples(n int) int {
|
||||
cnt := 0
|
||||
for a := 1; a <= n; a++ {
|
||||
for b := a; b <= n; b++ {
|
||||
sqC := a*a + b*b
|
||||
c := int(math.Sqrt(float64(sqC)))
|
||||
if c > n {
|
||||
break
|
||||
}
|
||||
if c*c == sqC { // c is integer
|
||||
cnt += 2
|
||||
if a == b {
|
||||
cnt -= 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cnt
|
||||
}
|
||||
|
||||
var _ = countTriples
|
||||
Loading…
Add table
Add a link
Reference in a new issue