Find Factorial of a Number in PHP using For Loop & Recursion

How to calculate factorial of a number in PHP. In this tutorial, I am going to discuss factorial program in PHP using recursion as well as iterative approach.

Before solving this problem let’s understand what is factorial?

What is Factorial?

Factorial of a non-negative integer n (n!), is the product of all positive integers less than or equal to n.

For example –

5! = 5 * 4 * 3 * 2 * 1 = 120

4! = 4 * 3 * 2 * 1 = 24

Find Common Elements in Two Arrays – Intersection of two Arrays

Write a c program to find common elements in two arrays.

Given two positive integer arrays arr1 and arr2 of lengths len1 and len2. We have to write a c code to find intersection of these two arrays. Both the arrays are sorted.

Let’s assume we have following two sorted arrays arr1 and arr2.

int arr1[] = {2,  3,  4,  5,  6};
int arr2[] = {4,  6,  7,  8,  9};

So the common elements in these two arrays is 4 and 6.

Find Common Elements in Two Arrays