Count numbers up to N that cannot be expressed as sum of at least two consecutive positive integersGiven a positive integer N, the task is to find the count of integers from the range [1, N] such that the integer cannot be expressed as sum of two or more consecutive positive integers.Examples:Input: N = 10Output: […]

Continue Readingimport math def get_polar_form(z): re, im = z r = (re * re + im * im) ** 0.5 if r: theta = math.asin(im / r) return (r, theta) else: return (0, 0) def Addition(z1, z2): r1, theta1 = z1 r2, theta2 = […]

Continue ReadingProgram to find the product of a number with a Mersenne Number Given an integer N and a Mersenne number M, the task is to print their product without using the ‘*’ operator.Note: Mersenne numbers are those numbers which are one less than a power of two. Examples: Input: N = 4, M = 15Output: […]

Continue ReadingGiven an array arr[] consisting of N integers, the task is to find the sum of all subsets from an array, whose sum is a Perfect Number. Examples: Input: arr[] = {5, 4, 6}Output: 6Explanation:All possible subsets from the array arr[] are:{5} → Sum = 5{4} → Sum = 4.{6} → Sum = 6.{5, 4} […]

Continue ReadingGiven a positive integer L, the task is to find all the Ramanujan Numbers that can be generated by any set of quadruples (a, b, c, d), where 0 < a, b, c, d ≤ L. Ramanujan Numbers are the numbers that can be expressed as sum of two cubes in two different ways.Therefore, Ramanujan […]

Continue ReadingGiven an array arr[] consisting of N integers, the task is to find the expression by using parenthesis ‘(‘ and ‘)’ and division operator ‘/’ to maximize the value of the expression of subsequent float division of array elements. Examples: Input: arr[] = {1000, 100, 10, 2}Output: “1000/(100/10/2)”Explanation:The value of the expression 1000/(100/10/2) can be […]

Continue ReadingSum of Fibonacci Numbers | Set 2 Given a positive number N, the task is to find the sum of the first (N + 1) Fibonacci Numbers. Examples: Input: N = 3Output: 4Explanation:The first 4 terms of the Fibonacci Series is {0, 1, 1, 2}. Therefore, the required sum = 0 + 1 + 1 […]

Continue ReadingCheck if all array elements can be converted to pronic numbers by rotating digits Given an array arr[] of size N, the task is to check if it is possible to convert all of array elements to a pronic number by rotating the digits of array elements any number of times. Examples: Input: {321, 402, […]

Continue Reading