Dixon factorization
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
module FactorizationUI (run) where
|
||||
|
||||
import Utils (askChoice, askNumber)
|
||||
import Factorization (fermatFactorization, pollardPminus1)
|
||||
import Factorization (fermatFactorization, pollardPminus1, dixon)
|
||||
|
||||
run :: IO ()
|
||||
run = do
|
||||
putStrLn "Factorization"
|
||||
putStrLn "1) Fermat factorization"
|
||||
putStrLn "2) Pollard p-1"
|
||||
putStrLn "3) Dixon"
|
||||
|
||||
choice <- askChoice 2
|
||||
choice <- askChoice 3
|
||||
|
||||
case choice of
|
||||
1 -> fermatUI
|
||||
2 -> pollardUI
|
||||
3 -> dixonUI
|
||||
_ -> error "Impossible"
|
||||
|
||||
fermatUI :: IO ()
|
||||
@@ -34,3 +36,13 @@ pollardUI = do
|
||||
putStrLn ("Other factor: " ++ show (n `div` factor))
|
||||
Nothing ->
|
||||
putStrLn "Failed to find a factor (try a different B or method)."
|
||||
|
||||
dixonUI :: IO ()
|
||||
dixonUI = do
|
||||
n <- askNumber "Enter an integer n > 1:"
|
||||
b <- askNumber "Enter the bound B:"
|
||||
x <- askNumber "Enter the max random integer x:"
|
||||
let (p, q) = dixon n b x
|
||||
putStrLn ("n = " ++ show n)
|
||||
putStrLn ("p = " ++ show p)
|
||||
putStrLn ("q = " ++ show q)
|
||||
|
||||
Reference in New Issue
Block a user