replace log.Fatal with cobra.CheckErr

This commit is contained in:
filifa
2025-08-27 21:33:44 -04:00
parent 51e1a97c43
commit 65c8ab4057
5 changed files with 14 additions and 18 deletions

View File

@@ -18,7 +18,6 @@ package cmd
import (
"fmt"
"log"
"math/big"
"github.com/spf13/cobra"
@@ -30,18 +29,18 @@ var n string
func jacobi(cmd *cobra.Command, args []string) {
x, ok := new(big.Int).SetString(a, 10)
if !ok {
log.Fatal("invalid input " + a)
cobra.CheckErr("invalid input " + a)
}
y, ok := new(big.Int).SetString(n, 10)
if !ok {
log.Fatal("invalid input " + n)
cobra.CheckErr("invalid input " + n)
}
mod := big.NewInt(2)
mod.Mod(y, mod)
if mod.Cmp(big.NewInt(0)) == 0 {
log.Fatal("modulus must be odd")
cobra.CheckErr("modulus must be odd")
}
z := big.Jacobi(x, y)