Saturday, 4 Dec 2021
Category: Numbers

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: […]

import 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 = […]

Program 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: […]

Given 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} […]

Number of subarrays consisting only of Pronic Numbers Given an array arr[] consisting of N positive integers, the task is to count the number of subarrays consisting only of pronic numbers. Examples: Input: arr[] = {5, 6, 12, 3, 4}Output: 3Explanation: The subarray that consists only of pronic numbers are: {6} {12} {6, 12} Therefore, […]

Given 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 […]

Given 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 […]

Sum 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 […]

Check 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, […]