Created
June 16, 2012 22:30
-
-
Save ChristianSiegert/2942682 to your computer and use it in GitHub Desktop.
Solution written in Go for challenge 2012-03-16 on ProgrammingPraxis.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func main() { | |
fmt.Println("Exercise from: http://programmingpraxis.com/2012/03/16/sum-of-squares-of-two-largest-of-three-values/") | |
fmt.Println("Exercise: Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.") | |
fmt.Println("sum_of_squares_of_largest_two_numbers(2, 3, 1):", sum_of_squares_of_largest_two_numbers(2, 3, 1)) | |
} | |
func sum_of_squares_of_largest_two_numbers(a, b, c float64) float64 { | |
return math.Pow(math.Max(a, b), 2) + math.Pow(math.Max(math.Min(a, b), c), 2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Console output: