Category Archives: Mathematical

Find politeness of a number

Given an integer n. Find politeness of number n. Politeness of a number is defined as the number of ways it can be expressed as the sum of consecutive integers. Input: n = 15 Output: 3 Explanation: There are only three ways to express 15 as sum of consecutive integers i.e., 15 = 1 +… Read More »

Superperfect Number

Given an integer n. Check whether the number n is superperfect number or not. A superperfect number is a positive integer which satisfies σ2(n) = σ(σ(n)) = 2n, where σ is divisor summatory function. Input: n = 16 Output: yes Explanation: 16 is a superperfect number as σ(16) = 1 + 2 + 4 +… Read More »

Difference of two large numbers

Given two numbers as strings. The numbers may be very large (may not fit in long long int), the task is to find difference of these two numbers. Examples: Input : str1 = “11443333311111111100”, str2 = “1144422222221111” Output : 11442188888888889989 Input :str1 = “122387876566565674”, str2 = “31435454654554” Output : 122356441111911120 This is simple based on… Read More »

Refactorable number

Given an integer n. Check whether the number is refactorable or not. A refactorable number is an integer n that is divisible by count of all it’s divisors. Input: n = 8 Output: yes Explanation: 8 has 4 divisors: 1, 2, 4, 8 Since 8 is divisible by 4 therefore 8 is refactorable number. Input… Read More »