# Tag Archives: number-theory

## Count all prime numbers in a given range whose sum of digits is also prime

Given two integers L and R, the task is to find the count of total numbers of prime numbers in the range [L, R] whose… Read More »

## Min number of operations to reduce N to 0 by subtracting any digits from N

Given a number N, the task is to find the minimum number of operations required to reduce the number N to zero by subtracting the… Read More »

## Count of distinct power of prime factor of N

Given a positive integer N, the task is to find the total number of distinct power of prime factor of the given number N. Examples:… Read More »

## Count of subsequences of length 4 in form (x, x, x+1, x+1) | Set 2

Given a large number in form of string str of size N, the task is to count the subsequence of length 4 whose digit are… Read More »

## Sum of all divisors from 1 to N | Set 2

Given a positive integer N, the task is to find the sum of divisors of first N natural numbers. Examples: Input: N = 4 Output:… Read More »

## Count of triplets in a given Array having GCD K

Given an integer array arr[] and an integer K, the task is to count all triplets whose GCD is equal to K. Examples: Input: arr[]… Read More »

## Check if a number exists with X divisors out of which Y are composite

Given two integers X and Y representing total number of divisors and the number of composite divisors respectively, the task is to check if there… Read More »

## Check if given number contains a digit which is the average of all other digits

Given an integer N, the task is to check whether N contains a digit D such that it is the average of all other digits… Read More »

## All possible values of floor(N/K) for all values of K

Given a function f(K) = floor(N/K) (N>0 and K>0), the task is to find all possible values of f(K) for a given N where K… Read More »

## Find two numbers whose difference of fourth power is equal to N

Given an integer N, the task is to find two non-negative integers X and Y such that X4 – Y4 = N. If no such… Read More »

## Sum of GCD of all numbers upto N with N itself

Given an integer N, the task is to find the sum of Greatest Common Divisors of all numbers up to N with N itself. Examples:… Read More »

## Last digit in a power of 2

Given a number n, we need to find the last digit of 2n Input : n = 4 Output : 6 The last digit in… Read More »

## Count of nodes having odd divisors in the given subtree for Q queries

Given a binary tree and Q queries where each query contains a node of the binary tree, the task is to count the number of… Read More »

## Program to Convert BCD number into Decimal number

Given a BCD (Binary Coded Decimal) number, the task is to convert the BCD number into it’s equivalent Decimal number. Examples: Input: BCD = 100000101000… Read More »

## Split a number as sum of K numbers which are not divisible by K

Given two numbers N and K, the task is to split this number into K positive integers such that their sum is equal to N… Read More »