Tag Archives: Scala

Find GCD of two numbers

Given two numbers A and B, the task is to calculate GCD of A and B. Examples: Input : A = 4, B = 6 Output : 2 Input : A = 5, B = 10 Output : 5 GCD (Greatest Common Divisor) of two number is the largest number that divides both of them. A simple solution… Read More »

Find the Nth Fibonacci Number

Given a number N, the task is to find Nth Fibonacci number. The Fibonacci numbers are the numbers in the following integer series. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……. In this series, each number is the sum of the two preceding ones starting from 0 and 1. Examples: Input :… Read More »