From d07d4f0dd1d0d7d0ac24731cfaf8246732209e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Mon, 7 Oct 2019 00:03:34 +0200 Subject: [PATCH] fix isprime --- isprime/isprime.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/isprime/isprime.go b/isprime/isprime.go index 12cd0b2..8311914 100644 --- a/isprime/isprime.go +++ b/isprime/isprime.go @@ -5,6 +5,8 @@ import ( "log" "net/http" "os" + "math" + "strconv" ) func handler(w http.ResponseWriter, r *http.Request) { @@ -13,16 +15,16 @@ func handler(w http.ResponseWriter, r *http.Request) { if err != nil { return "", fmt.Errorf("Failed to parse %s as int! %v", target, err) } - logrus.Infof("Checking if %s is prime", target) + log.Print("Checking if %s is prime", target) if num <= 1 { - return fmt.Fprintf(w,"%d is not prime", num), nil + return 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.Fprintf(w,"%d is not prime", num), nil + return fmt.Sprintf("%d is not prime", num), nil } } - return fmt.Fprintf(w,"%d is prime", num), nil + return fmt.Sprintf("%d is prime", num), nil } func main() {