don't quit on invalid input
This commit is contained in:
parent
67a6ce9b69
commit
991a8b3c76
|
|
@ -29,18 +29,14 @@ var rounds uint
|
||||||
func isprime(cmd *cobra.Command, args []string) {
|
func isprime(cmd *cobra.Command, args []string) {
|
||||||
x := new(big.Int)
|
x := new(big.Int)
|
||||||
|
|
||||||
primes := make([]bool, len(args))
|
for _, s := range args {
|
||||||
for i, s := range args {
|
|
||||||
_, ok := x.SetString(s, 10)
|
_, ok := x.SetString(s, 10)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Fatal("invalid input " + s)
|
log.Print("invalid input " + s)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
primes[i] = x.ProbablyPrime(int(rounds))
|
fmt.Println(x.ProbablyPrime(int(rounds)))
|
||||||
}
|
|
||||||
|
|
||||||
for _, b := range primes {
|
|
||||||
fmt.Println(b)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue