Programming Articles

Page 1169 of 2547

Find (a^b)%m where 'a' is very large in C++

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 326 Views

In this tutorial, we are going to solve the equation (ab)%m where a is a very large number.The equation (ab)%m=(a%m)*(a%m)...b_times. We can solve the problem by finding the value of a%m and then multiplying it b times.Let's see the steps to solve the problem.Initialize the numbers a, b, and m.Write a function to find the a%m.Initialize the number with 0.Iterate over the number in string format.Add the last digits to the number.Update the number with number modulo them.Get the value of a%m.Write a loop that iterates b times.Multiply the a%m and modulo the result with m.Print the result.ExampleLet's see the ...

Read More

What is Java reg ex to check for date and time?

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 2K+ Views

To match a regular expression with the given string You need to:.Compile the regular expression of the compile() method of the Pattern class.Get the Matcher object bypassing the required input string as a parameter to the matcher() method of the Pattern class.The matches() method of the Matcher class returns true if a match occurs else it returns false. Therefore, invoke this method to validate the data.ExampleFollowing is a Java regular expression example matches only dateimport java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Sample {    public static void main(String args[]){       //Creating the list to store ...

Read More

Find A and B from list of divisors in C++

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 221 Views

In this tutorial, we are going to solve the below problem.Given an array of integers, we have to find two numbers A and B. All the remaining numbers in the array are the divisors of A and B.If a number is a divisor of both A and B, then it will present twice in the array.Let's see the steps to solve the problem.The max number in the array is one of the numbers from A and B. Let's say it is A.Now, B will be the second-largest number or the number which is not a divisor of A.ExampleLet's see the ...

Read More

Find 2^(2^A) % B in C++

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 180 Views

In this tutorial, we are going to write a program to evaluate the equation 2^(2^A) % B.We are going to find the value of the equation using a recursive function. Let's see the steps to solve the problem.Write a recursive function that takes 2 arguments A and B.If A is 1, then return 4 % B as 2^(2^1) % B = 4 % B.Else recursively call the function with A-1 and b.Return the result^2%B.Print the solutionExampleLet's see the code.#include using namespace std; long long solveTheEquation(long long A, long long B) {    // 2^(2^1) % B = 4 % ...

Read More

How to change the order of elements in a list in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 2K+ Views

A list in R can contain many types of elements such as vector, data frame, matrices, etc. Sometimes the order of these elements matter, especially in situations when we have large size elements because it is difficult to view large size elements of a list. This ordering can be done with the help of single square bracket and combine operator c as shown in the below examples.ExampleList1

Read More

Find (1^n + 2^n + 3^n + 4^n) mod 5 in C++

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 327 Views

In this tutorial, we are going to solve the following problem.Given an integer n, we have to find the (1n+2n+3n+4n)%5The number (1n+2n+3n+4n) will be very large if n is large. It can't be fit in the long integers as well. So, we need to find an alternate solution.If you solve the equation for the number 1, 2, 3, 4, 5, 6, 7, 8, 9 you will get 10, 30, 100, 354, 1300, 4890, 18700, 72354, 282340 values respectively.Observe the results of the equation carefully. You will find that the last digit of the equation result repeats for every 4th number. ...

Read More

How to perform Wilcoxon test for all columns in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 2K+ Views

Performing Wilcoxon test for all columns in an R data frame means that we want to use this test for single samples and the Wilcoxon test for single sample is used to test for the median of the sample, whether the median is equal to something or not. And if we do not provide any value then zero is the reference value. To perform Wilcoxon test for all columns can be done with the help of apply function and wilcox.test as shown in the below example.Consider the below data frame −Examplex1

Read More

What is the difference between na.omit and na.rm in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 3K+ Views

The na.omit performs any calculation by considering the NA values but do not include them in the calculation, on the other hand, na.rm remove the NA values and then perform any calculation. For example, if a vector has one NA and 5 values in total then their sum using na.omit will be calculated by excluding NA and by using na.rm it will be calculated by removing NA.Consider the below data frame −Examplex1

Read More

How to split comma separated values in an R vector?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 12K+ Views

The splitting of comma separated values in an R vector can be done by unlisting the elements of the vector then using strsplit function for splitting. For example, if we have a vector say x that contains comma separated values then the splitting of those values will be done by using the command unlist(strsplit(x,",")).Examplex1

Read More

Find a number that divides maximum array elements in C++

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 260 Views

In this tutorial, we are going to find the number that is divided into maximum elements in the given array.Let's see the steps to solve the problem.Initialize the array and a variable to store the result.Iterate over the array.Initialize the counter variable.Iterate over the array again.Increment the counter if the current element is divisible by the array element.Update the result if the current count is maximum.Print the result.ExampleLet's see the code.#include using namespace std; int numberWithMaximumMultiples(int arr[], int n) {    int result = -1;    for (int i = 0; i < n; i++) {       ...

Read More
Showing 11681–11690 of 25,466 articles
Advertisements