Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 

Repository files navigation

Mathematics

I will collect the solution of different mathematical problems addressed in a variety of programming languages.


Factorization

This is a problem proposed for undergraduate students of Mathematical Sciences at the University of Buenos Aires (FCEyN, UBA). The problem has to be solved in the haskell programming language. Haskell is a purely funcional programming language, that is specially suitable for mathematical purposes.

Exercise Write a function factorizar :: Integer -> [(Integer,Integer)] that receives as a parameter an integer n >= 1 and returns a list representing the factorization of n. Formally, the list has to be structured like
[(p1; k1), (p2, k2),...,(pm, km)] such that

  1. p1, p2, . . . , pm and k1, k2, . . . ,km are positive integers.
  2. p1, p2, . . . , pm are primes.
  3. p1 < p2 < . . . < pm.
  4. p1k1 x p2k2 x . . . x pmkm = n

For the value 1, the answer is an empty list, because it has no prime divisors.

Examples of the factorizar function

Query in terminal Should return
factorizar 6 [(2,1),(3,1)]
factorizar 7 [(7,1)]
factorizar 81 [(3,4)]
factorizar 1176 [(2,3),(3,1),(7,2)]
factorizar 1 [ ]
factorizar 0 *** Exception: ...
factorizar -1 *** Exception: ...

Solution

While the Riemann Hypothesis remains unsolved, there is no easy way in which we can affirm that a number is prime. However, there are some recursive algorithms that let us deal with this situation. I have chosen the one called The sieve of Eratosthenes.

References

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages