factorization - Implementing a factorisation method in Haskell -


I am doing project over and after some searches, the factors of a number were found to quickly find.

I already have a module to find the main power factors of a number such as:

  main & gt; The prime power factor is 196 [(2,2), (7,2)]  

It is basically showing that: 2 ^ 2 * 7 ^ 2 = = 1 9 6 . To give the factors of 196 in such a way, from here I have to find all the parallels of those powers:

  • (2 ^ 0) (7 ^ 0) = 1
  • (2 ^ 1) (7 ^ 0) = 2
  • (2 ^ 2) (7 ^ 0) = 4
  • (2 ^ 0) (7 ^ 1) = 7
  • (2 ^ 1) (7 ^ 1) = 14
  • (2 ^ 2) (7 ^ 1) = 28
  • ( 2 ^ 0) (7 ^ 2) = 49
  • (2 ^ 1) (7 ^ 2) = 98

I came up with:

  factor n = [A | A & lt; -MAP FACS (Prime Power Factor), Y & LT; - [0 .. (SD $ $ Last PactForce Factor N)]] Where FACS (X, Y) = (X, Y) RSq n = toInteger $ round $ sqrt (fromInteger n) psr n = last $ dropWhile (& lt ; = RSq n) $ factor np = foldl '(*) $ 1 when taking $ 1 (& lt; 190) primes answer = (psr p) `Mod` (10 ^ 16)  

But my problem is that the factor does not work properly, I want it to be allowed through all the possible values ​​of the exponent for each major factor and then search for the factor to the product do. To bring back the factors of n

How Can I Modify Some Code For Golf I have written a good power set function which is very easy.

  powerSet [] = [] PowerSet (x: xs) = xs: map (x :) (powerSet xs) ++ (PowerSet X)  

The lack of this algorithm is that it does not include the original set, though it is perfect for you because it does not look like this.

  ppfToList = concatMap (\ (x, x, x, x, x, x, x, x, x, x,  

of these helpers Using a number, a list of factors arises from the number

factor n = nb. Map product power installs. PpfToList Prime PowerFactors $ n - You will be able to decide You can add a call to `sort` for

This type of algorithm is probably a bit hard to express in terms of a list.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -