# Tag Archives: Natural Numbers

## Square root of a number by Repeated Subtraction method

Given an integer N, the task is to find its perfect square root by repeated subtraction only. Examples: Input: N = 25 Output: 5 Input:… Read More »

## Count of natural numbers in range [L, R] which are relatively prime with N

Given three integers N, L, and R. The task is to calculate the number of natural numbers in the range [L, R] (both inclusive) which… Read More »

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

Given a positive integer N, the task is to find the sum of divisors of all the numbers from 1 to N. Examples: Input: N… Read More »

## Count sequences of length K having each term divisible by its preceding term

Given two integer N and K, the task is to find the number of sequence of length K consisting of values from the range [1,… Read More »

## Maximize count of corresponding same elements in given permutations using cyclic rotations

Given two permutations P1 and P2 of numbers from 1 to N, the task is to find the maximum count of corresponding same elements in… Read More »

## Sum of series formed by difference between product and sum of N natural numbers

Given a natural number N, the task is to find the sum of the series up to Nth term where the ith term denotes the… Read More »

## Minimum number of adjacent swaps required to convert a permutation to another permutation by given condition

Given a permutation P of size N, having values from 1 to N. the task is to find the minimum number of adjacent swaps required… Read More »

## Find index after traversing a permutation Array of 1 to N by K steps

Given an integer K and an index array arr[] of length N which contains elements in the range [1, N], the task is to find… Read More »

## Generate all numbers up to N in Lexicographical Order

Given an integer N, the task is to print all numbers up to N in Lexicographical order. Examples: Input: N = 15 Output: 1 10… Read More »

## Average of Cubes of first N natural numbers

Given a positive integer N, the task is to find the average of cubes of first N natural numbers. Examples:   Input: N = 2 Output: 4.5 Explanation: For integer… Read More »

## Count of pairs in a given range with sum of their product and sum equal to their concatenated number

Given two numbers A and B, the task is to find the count of pairs (X, Y) in range [A, B], such that (X *… Read More »

## Sort permutation of N natural numbers using triple cyclic right swaps

Given an array arr[] of size N which contains the permutations of the N natural numbers, the task is to sort the permutations of N… Read More »

## Compositorial of a number

Given a natural number N, the task is to find the Nth compositorial number. Compositorial of a number refers to the product of all the… Read More »

## Count of digits after concatenation of first N positive integers

Given a positive integer N, the task is to find the total number of digits in the concatenation of the first N positive integers. Examples:… Read More »

## Count of triplets of numbers 1 to N such that middle element is always largest

Given an integer N, the task is to count the number of ways to arrange triplets (a, b, c) within [1, N] in such a… Read More »