Category Archives: Mathematical

N-th root of a number

Given two numbers N and A, find N-th root of A. In mathematics, Nth root of a number A is a real number that gives A, when we raise it to integer power N. These roots are used in Number Theory and other advanced branches of mathematics. Refer Wiki page for more information. Examples: Input… Read More »

Largest subarray with GCD one

There is an array with n elements. Find length of the largest subarray having GCD equal to 1. If no subarray with GCD 1, then print -1. Examples: Input : 1 3 5 Output : 3 Input : 2 4 6 Output :-1 A simple solution is to consider every subarray and find its GCD… Read More »

Reversible numbers

A number is said to be a reversible if sum of the number and its reverse had only odd digits. The problem is to find out if a number is reversible or not. Examples: Input: 36 Output: Reversible number as 36 + 63 = 99 has only odd digits. Input: 409 Output: Reversible number as… Read More »

Multiplicative order

In number theory, given an integer A and a positive integer N with gcd( A , N) = 1, the multiplicative order of a modulo N is the smallest positive integer k with A^k( mod N ) = 1. ( 0 < K < N ) Examples: Input : A = 4 , N =… Read More »