Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 1.8 KB

Exercises.md

File metadata and controls

37 lines (25 loc) · 1.8 KB

List of Excercises

  1. Fibonacci sequence
  2. Greatest common divisor
  3. Primality test
  4. Prime factors
  5. Small Calculator Interpreter

Excercise 1: Fibonacci sequence

Write a function fib that received an integer n computes the n-th element of the Fibonacci sequence.

(Solution)

Excercise 2: Greatest common divisor

Write a function gcd that received two integers a and b as input computes their Greatest common divisor.

(Solution)

Excercise 3: Primality test

Write a function isPrime that received an integer n checks if it is prime or not.

(Solution)

Excercise 4: Prime factors

Write a function primeFactors that received an integer n computes the list of its prime factors.

(Solution)

Excerice 5: Interpreter of a Small Calculator.

Develop an interepreter of a Small Calculator. This calculator has the following keys:

  • digits: 0,1,2,3,4,5,6,7,8,9;
  • operations: +,-,*,/;
  • commands: ., =.

(Solution in F#) (Solution in Java)