Skip to content

bartlomiejborzucki/haskellSimpleProblems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

haskellSimpleProblems

Solving simple problems in Haskell.

List of problems:

###problem 1

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.

###problem 3

The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?

###problem 4

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99. Find the largest palindrome made from the product of two 3-digit numbers.

###problem 5

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?

###problem 6

The sum of the squares of the first ten natural numbers is, 1? + 2? + ... + 10? = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)? = 55? = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 385 = 2640. Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

###problem 7

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number?

###problem 9

A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc.

###problem 10

The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million.

###problem 16

215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 21000?

###problem 20

n! means n (n 1) ... 3 2 1 Find the sum of the digits in the number 100!

###suma

Write new function which takes integer (n) and returns the sum of positive even numbers that are less or equal than n. You get the remainder from the devision of number a by b using function mod a b.

###prime

Two ways of showing prime numbers

###fib

fibonacci by definition

###odleglosc

Create function which/that calculates a distance between two points on a plane ( function must take four coordinates x1, y1, x2, y2). Then write function, which will take coordinates of vertex triangle (six numbers) and will return triangle perimeter. Function which/that calculates the perimeter should use function that returns distance between two points

###operator

Define new operator +*+, which performs addition of two numbers and increases the result additionally by 1 (e.g. 2 +*+ 3 = 6), so the operator will be executed after addition and multiplication (e.g 1 +2 +*+ 3 * 3 = 13)

###nwd

Greatest common divisor for two natural numbers

###imie

Define new function that takes your name and returns welcome message (e.g. After taking a name Tomek function returns “Witaj Tomek”). To concatinate strings your should use operator “++”

###insertionsort

Sorting numbers using insertion sort.

###mergesort

Sorting numbers using merge sort.

###qsort

Sorting numbers using quick sort.

###selectionsort

Sorting numbers using selection sort.

###binsearch

The function searches numbers using binary search

###treesort

Sorting numbers using tree sort.

###sublist

The function shows all sublists from entrance list which is taken as an argument.

###perm

The function shows all permutations of the entrance list

###trojkat pitagorejski

The function shows all Pythagorean triples so the triples in which all sides fulfill the equation a^2+b^2=c^2. This function is lazy.

About

Solving simple problems in Haskell.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published