Skip to content

Category Archives: Mathematical

Given a number n, find two pairs that can represent the number as sum of two cubes. In other words, find two pairs (a, b)… Read More
Given a number n, find two pairs that can represent the number as sum of two cubes. In other words, find two pairs (a, b)… Read More
Given a positive integer n, find the no of factors in n! where n <= 105. Examples : Input : n = 3 Output :… Read More
Given two integers a and b, how can we evaluate the sum a + b without using operators such as +, -, ++, –, …?… Read More
Given a number n, find number of ways we can add 3 non-negative integers so that their sum is n. Examples : Input : n… Read More
Given an array of n numbers, find LCM of it. Input : {1, 2, 8, 3} Output : 24 Input : {2, 7, 3, 9,… Read More
Given an array, find the number of subarrays whose sum is even. Example :  Input : arr[] = {1, 2, 2, 3, 4, 1} Output… Read More
A Diophantine equation is a polynomial equation, usually in two or more unknowns, such that only the integral solutions are required. An Integral solution is… Read More
Given two numbers ‘a’ and ‘b’. Find the minimum difference between any terms in shifted infinite tables of ‘a’ and ‘b’, given shifts ‘x’ and… Read More
Given a number positive number n, find value of f0 + f1 + f2 + …. + fn where fi indicates i’th Fibonacci number. Remember… Read More
Prerequisites : Grundy Numbers/Nimbers and MexWe have already seen in Set 2 (https://www.geeksforgeeks.org/combinatorial-game-theory-set-2-game-nim/), that we can find who wins in a game of Nim without… Read More
How to find the largest number with given digit sum s and number of digits d? Examples: Input : s = 9, d = 2… Read More
Given a positive number, find out all combinations of positive numbers that adds upto that number. The program should print only combinations, not permutations. For… Read More
In share trading, a buyer buys shares and sells on a future date. Given the stock price of n days, the trader is allowed to… Read More
We strongly recommend to refer below article as a prerequisite of this. Combinatorial Game Theory | Set 1 (Introduction) In this post, Game of Nim… Read More