Last active
April 26, 2017 19:23
-
-
Save muety/93a3ba758e2b47fa8d8fe7f62929f013 to your computer and use it in GitHub Desktop.
Delta Karlsruhe Gewinnspiel
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" | |
"time" | |
) | |
func main() { | |
N := int64(751395478255) | |
n := N | |
factor := int64(0) | |
start := time.Now() | |
for i := int64(2); i < n; i++ { | |
for n%i == 0 { | |
factor = i | |
n = n / i | |
} | |
} | |
if n > 1 { | |
factor = n | |
} | |
fmt.Printf("Largest prime factor of %v is %v\n", N, factor) | |
fmt.Printf("Execution time: %s\n", time.Since(start)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment