remove return from isprime
This commit is contained in:
parent
d07d4f0dd1
commit
cd3249c51f
@ -13,18 +13,18 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
target := os.Getenv("TARGET")
|
||||
num, err := strconv.Atoi(target)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Failed to parse %s as int! %v", target, err)
|
||||
fmt.Errorf("Failed to parse %s as int! %v", target, err)
|
||||
}
|
||||
log.Print("Checking if %s is prime", target)
|
||||
if num <= 1 {
|
||||
return fmt.Sprintf("%d is not prime", num), nil
|
||||
fmt.Sprintf("%d is not prime", num), nil
|
||||
}
|
||||
for i := 2; i <= int(math.Floor(float64(num)/2)); i++ {
|
||||
if num%i == 0 {
|
||||
return fmt.Sprintf("%d is not prime", num), nil
|
||||
fmt.Sprintf("%d is not prime", num), nil
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%d is prime", num), nil
|
||||
fmt.Sprintf("%d is prime", num), nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
Loading…
Reference in New Issue
Block a user