Find the Area of a Triangle Given Three Sides – Heron’s Formula

Objective – Given three sides of triangle, write a program to find the area of a triangle. Heron’s Formula for finding area of triangle: First find the semi parameter of a triangle using formula, s= (a+b+c)/2 where a, b, c are three sides of triangle and s will the semi parameter. Then use the below … Read more Find the Area of a Triangle Given Three Sides – Heron’s Formula

Find Factorial of a given Number

Objective: Given a number, write a program to find factorial of that number. What is Factorial Number? In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. The value of 0! is 1, according to the convention for an empty product N! = n*(n-1)*(n-2)*…..*2*1 Example: 5! = 5 x 4 x 3 … Read more Find Factorial of a given Number

Euclidean algorithm – Greatest Common Divisor(GCD)

The greatest common divisor (GCD) of two or more integers, when at least one of them is not zero, is the largest positive integer that divides the numbers without a remainder. For example, the GCD of 10 and 15 is 5. (Source – Wiki – http://en.wikipedia.org/wiki/Greatest_common_divisor).

Euclidean Algorithm : The greatest common divisor of two numbers remains the same if the larger number is replaced by its difference with the smaller number. If we keep repeat this process until one of the number becomes 0, then other number will be the GCD. We can solve this recursively.

Read moreEuclidean algorithm – Greatest Common Divisor(GCD)