massively improve performance with dynamic programming

This commit is contained in:
filifa
2025-09-16 22:23:39 -04:00
parent 4d8f12e1a2
commit ddbb892748
2 changed files with 45 additions and 36 deletions

View File

@@ -19,6 +19,7 @@ package cmd
import (
"fmt"
"math/big"
"strconv"
"github.com/spf13/cobra"
"scm.dairydemon.net/filifa/mathtools/internal/lib"
@@ -31,13 +32,13 @@ var stirlingBottom string
var stirlingUnsigned bool
func stirling(cmd *cobra.Command, args []string) {
n, ok := new(big.Int).SetString(stirlingTop, 10)
if !ok {
n, err := strconv.Atoi(stirlingTop)
if err != nil {
cobra.CheckErr("invalid input " + stirlingTop)
}
k, ok := new(big.Int).SetString(stirlingBottom, 10)
if !ok {
k, err := strconv.Atoi(stirlingBottom)
if err != nil {
cobra.CheckErr("invalid input " + stirlingBottom)
}