Ravi Ranjan has Published 148 Articles

How to calculate combination and permutation in C++?

Ravi Ranjan

Ravi Ranjan

Updated on 02-May-2025 15:19:10

13K+ Views

Combination and permutation are a part of combinatorics. The permutation is known as the different arrangements that a set of elements can make if the elements are taken one at a time, some at a time, or all at a time. Combination is the different ways of selecting elements if ... Read More

Which is the fastest algorithm to find prime numbers using C++?

Ravi Ranjan

Ravi Ranjan

Updated on 02-May-2025 13:17:12

3K+ Views

The fastest algorithm to find the prime numbers is the Sieve of Eratosthenes algorithm. It is one of the most efficient ways to find the prime numbers smaller than n when n is smaller than around 10 million. In this article, we have a given number as 'num'. Our ... Read More

C++ Program to Perform Fermat Primality Test

Ravi Ranjan

Ravi Ranjan

Updated on 25-Apr-2025 11:22:19

949 Views

Fermat's Little theorem states that if 'p' is a prime number and 'a' is an integer that is not divisible by p, then a^(p-1) ≡ 1 modulo p or a^(p-1) mod p = 1. We will use Fermat's Little theorem to test whether the given number is a prime number ... Read More

C++ Program to Implement Euler Theorem

Ravi Ranjan

Ravi Ranjan

Updated on 23-Apr-2025 17:13:22

620 Views

Euler's theorem states that if two numbers (a and n), are co-prime i.e. gcd(a, n)=1, then 'a' raised to the power of Euler's totient function of n (a^φ(n)) is congruent to 1 modulo n i.e. a^φ(n) ≡ 1 (mod n). The Euler's Totient Function is denoted as φ(n) and represents ... Read More

C++ Program to Implement Fermat’s Little Theorem

Ravi Ranjan

Ravi Ranjan

Updated on 23-Apr-2025 17:07:46

929 Views

Fermat's Little Theorem states that if p is a prime number and a is an integer not divisible by p, then a^(p-1) is congruent to 1 modulo p. It can be represented as a(p-1) ≡ 1 (mod p). It can also be said that if any integer a is raised ... Read More

C++ Program to Implement Park-Miller Random Number Generation Algorithm

Ravi Ranjan

Ravi Ranjan

Updated on 23-Apr-2025 17:02:49

553 Views

The Park-Miller algorithm is a type of linear congruential generator (LCG) that is used to generate pseudo-random numbers. It is also called the minimal standard random number generator. The general formula of a random number generator (RNG) of this type is: X_{k+1} = g X(k) mod n where the modulus ... Read More

C++ Program to Implement Russian Peasant Multiplication

Ravi Ranjan

Ravi Ranjan

Updated on 22-Apr-2025 16:50:55

549 Views

The Russian Peasant multiplication is used to multiply two numbers without using the multiplication operator. It involves constant use of halving and doubling the numbers. In this article, we have two integers, our task is to find the product of these two integers by implementing russian peasant multiplication in C++. ... Read More

C++ Program to Generate Random Numbers Using Probability Distribution Function

Ravi Ranjan

Ravi Ranjan

Updated on 22-Apr-2025 11:38:55

2K+ Views

The probability density function (pdf) is a function that describes the relative likelihood for this random variable to take on a given value. It is also called as density of a continuous random variable. The probability of the random variable fall within a particular range of values is given by ... Read More

C++ Program to Generate Random Numbers Using Middle Square Method

Ravi Ranjan

Ravi Ranjan

Updated on 22-Apr-2025 11:38:27

1K+ Views

The middle-square method is one of the simplest methods of generating random numbers. This method will either begin repeatedly generating the same number or cycle to a previous number in the sequence and loop indefinitely. For a generator of n-digit random numbers, the period can be no longer than the ... Read More

C++ Program to Implement Interpolation Search Algorithm

Ravi Ranjan

Ravi Ranjan

Updated on 21-Apr-2025 14:40:31

1K+ Views

The interpolation search is an improved version of the binary search. The list is divided using the mid element in the binary search whereas the interpolation search algorithm tries to locate the exact position using the interpolation formula. For this algorithm to work properly, the data collection should be in ... Read More

Advertisements