Sunday, 28 Nov 2021
Category: divisibility

Given a string S consisting of N digits and an integer K, the task is to count the number of ways to remove digits from the number formed by the concatenating the string S, K number of times, such that the resulting string is divisible by 5. Since count can be very large, so print […]

Given a string str[] number N, the task is to calculate the number of ways to make the given number divisible by 3 by changing at most one digit of the number.Examples:Input: str[] = “23”Output: 7Explanation: Below are the numbers that can be made from the string which are divisible by 3 – 03, 21, […]

Given three integers, C0, C1 and C2 frequencies of 0s, 1s and 2s in a group S. The task is to find the maximum number of groups having the sum divisible by 3, the condition is the sum(S) is divisible by 3 and the union of all groups must be equal to SExamples:Input: C0 = […]

Given a binary string S, the task is to find that the decimal representation of the given binary string is divisible by integer K or not.Examples:Input: S = 1010,  k = 5Output: YesExplanation: Decimal representation of 1010 (=10) is divisible by 5Input: S = 1010,  k = 6Output: NoApproach:  Since the modulo operator is distributive […]

Generate an N-length array having maximum element minimized and sum of array elements divisible by KGiven two positive integers N and K, the task is to minimize the maximum element of the array formed such that the sum of array elements is positive and divisible by K.Examples:Input: N = 4, K = 50Output: 13Explanation The […]

Sum of array elements possible by appending arr[i] / K to the end of the array K times for array elements divisible by KGiven an array arr[] consisting of N integers and an integer K, the task is to find the sum of the array elements possible by traversing the array and adding arr[i] / […]

import java.io.*; import java.lang.*; import java.util.*; class GFG {               static boolean isPrime(int n)     {                          if (n

Print digits for each array element that does not divide any digit of that element Given an array arr[] consisting of N positive integers, the task for each array element arr[i] is to find all the digits from [0, 9] that does not divide any digit present in arr[i]. Examples: Input: arr[] = {4162, 1152, […]

Smallest positive integer that does not divide any elements of the given array Given an array arr[] consisting of N positive integers, the task is to determine the smallest positive integer K such that none of the array element is not divisible by K. If no such integer is Examples: Input: arr[] = {3, 2, […]