/**
* @param num1: An integer
* @param num2: An integer
* @param num3: An integer
* @return: an interger
*/
func MaxOfThreeNumbers(num1 int, num2 int, num3 int) int {
// write your code here
max1 := Max(num1, num2)
max2 := Max(max1, num3)
return max2
}
func Max(num1, num2 int) int {
max := 0
if num1 > num2 {
max = num1
} else {
max = num2
}
return max
}
/**
* @param nums: the list of numbers
* @return: return the maximum number.
*/
import "sort"
func MaxNum(nums []int) int {
// write your code here
sort.Ints(nums)
return nums[len(nums) - 1]
}
/**
* @param n: an integer
* @return: return all prime numbers within n.
*/
func Prime(n int) []int {
// write your code here
slice := []int{}
for i := 2; i <= n; i++ {
if isPrime(i) {
slice = append(slice, i)
}
}
return slice
}
func isPrime(n int) bool {
if n < 2 {
return false
}
for i := 2; i <= n/i; i++ {
if n%i == 0 {
return false
}
}
return true
}