Wednesday, 1 Dec 2021
Category: HCF

Minimum possible value of D which when added to or subtracted from K repeatedly obtains every array elementGiven an array arr[] of size N and an integer K, the task is to find the maximum possible value of D, such that every array element can be obtained, starting from the initial value of K, by […]

Print all numbers that are divisors of N and are co-prime with the quotient of their divisionGiven a positive integer N, the task is to print all the numbers, say K, such that K is a divisor of N and K and N / K are coprime.Examples:Input: N = 12  Output: 1 3 4 12 […]

Sort an array in increasing order of GCD of their digitsGiven an array arr[] consisting of N positive integers, the task is to sort the array arr[] according to the increasing order of GCD of digits of each element. If GCD of two or more elements are the same then, sort according to their values.Examples:Input: […]

import java.io.*;import java.lang.*;import java.util.*;class GFG{static int gcd(int a, int b){             if (a == 0)        return b;        return gcd(b % a, a);}static void update(int arr[], int n){             for(int i = 0; i < n; i++)    {                                 int d = 0;                        int coPrime = -1;                for(int j = 2; j

def GCD(a, b):     if not b:         return a     return GCD(b, a % b)    def GCDArr(a):     ans = a[0]     for i in a:         ans = GCD(ans, i)     return ans    def findSubseqUtil(a, b, ans, k, i):                  if len(ans) == len(a):                              if GCDArr(ans) == k:             print(ans)             return […]