Found 1862 Articles for Data Structure

Sum of product of Consecutive Binomial Coefficients

Rinish Patidar
Updated on 28-Aug-2023 17:54:20

131 Views

The problem statement includes printing the sum of product of consecutive binomial coefficients for any positive number, N which will be the user input. The positive coefficients in the binomial expansion of any term are called binomial coefficients. These binomial coefficients can be found out using Pascal's triangle or a direct formula. The formula to calculate the binomial coefficient: $$\mathrm{^nC_{r}=\frac{n!}{(n-r)!r!}}$$ where, n and r can be any positive numbers and r should never be greater than n. Note : The value of 0! is always equal to 1. In this problem, we will be given a positive number N and ... Read More

Sum of digits written in different bases from 2 to n-1

Rinish Patidar
Updated on 28-Aug-2023 17:50:33

64 Views

The problem statement includes printing the sum of digits of N, which will be the user input, when written in different bases from 2 to N−1. In this problem, we will be provided any positive integer N and we need to represent that number in a different base numeral system from 2 to N−1 and find the sum of the digit of each different base numeral system. In the base−n numeral system, every digit of the representation of any number in that numeral system from right represents the number of times power of n from 0 to 31. For example, ... Read More

Sum of bitwise OR of all possible subsets of given set

Rinish Patidar
Updated on 28-Aug-2023 17:46:06

134 Views

The problem statement includes printing the sum of bitwise OR of all possible subsets of a given set. A set is a collection of data of similar type. A subset of any set is a set containing few elements of the set or all the elements of the given set. The number of subsets of any set is given by $\mathrm{2^{n}−1}$, where n is the number of elements in the given set. For example, a={1, 2, 3, 4, 5} is the given set. {1}. {2, 3}, {1, 2, 3, 4} and so on are called subsets of a, as they ... Read More

Program to print the sum of the given nth term

Rinish Patidar
Updated on 28-Aug-2023 17:34:54

174 Views

The problem statement includes printing the sum of the series whose Nth term is given. The value of N will be given in the input. We need to find the sum of the sequence up to N where the Nth term of the sequence is given by: $$\mathrm{N^{2}−(N−1)^{2}}$$ Let’s understand the problem with the below examples: Input N=5 Output 25 Explanation − The value of N given is 5.The first 5 terms of the sequence are: $\mathrm{N=1, 1^{2}−(1−1)^{2}=1}$ $\mathrm{N=2, 2^{2}−(2−1)^{2}=3}$ $\mathrm{N=3, 3^{2}−(3−1)^{2}=5}$ $\mathrm{N=4, 4^{2}−(4−1)^{2}=7}$ $\mathrm{N=5, 5^{2}−(5−1)^{2}=9}$ The sum of the terms of the sequence until 5th ... Read More

Numbers within a range that can be expressed as power of two numbers

Rinish Patidar
Updated on 28-Aug-2023 15:39:32

132 Views

The problem statement includes printing the count of numbers within a range given that can be expressed as power of two numbers i.e. numbers which are perfect powers. The numbers which are known as perfect powers is the number which can be expressed as $\mathrm{x^{y}}$, where x>0 and y>1 for all integers. For example, 8 is a perfect power because it can be expressed as $\mathrm{2^{3}}$, which is equal to 8 hence it is considered as a perfect power. In this problem, we will be given a range as two positive integers in the input i.e. a and b ... Read More

Minimum digits to remove to make a number Perfect Square

Rinish Patidar
Updated on 28-Aug-2023 15:36:03

439 Views

The problem statement includes finding the minimum number of digits to remove from a number to make a number perfect square. A perfect square denoted as $\mathrm{x^{2}}$ is a positive integer which is a product of an integer with itself. We will be given a positive number N and we need to find the minimum number of digits we can remove from the number N to make it a perfect square i.e. such that it is a product of some integer with itself. For example, N=42 We can remove 1 digit from N i.e. 2 to make it a perfect ... Read More

Making zero array by decrementing pairs of adjacent

Rinish Patidar
Updated on 28-Aug-2023 15:34:10

56 Views

The problem statement includes making an array zero array by decrementing pairs of adjacent. The array will be given in the input and we can perform the operation on the array i.e. subtract 1 from ith and (i+1)th index where 0

Java Math subtractExact(long x, long y) method

Rinish Patidar
Updated on 28-Aug-2023 15:31:08

157 Views

We will discuss the Java Math subtractExact(long x, long y) method in Java language and understand its functionalities and working. The subtractExact()is an inbuilt function in the Java Math library. The function returns the difference between the two parameters passed as arguments in the function. The function returns an exception when the returned value overflows the range of values of a particular data type. The syntax of the subtractExact() function long a; long b; long subtractExact(long a, long b); The parameters passed in the function are a and b which are of long data types. The function returns ... Read More

Hoax Number

Rinish Patidar
Updated on 28-Aug-2023 15:28:20

158 Views

The problem statement includes checking if the given number N, which will be the user input, is a hoax number or not. A Hoax number is a composite number whose sum of digits of its distinct prime factors is equal to the sum of the digits of the composite number itself. Since 1 is not a prime number, we don’t consider 1 as a sum of digits of distinct prime numbers. If a prime number is a factor of the composite number more than once, it is just considered once while taking the sum of digits of prime factors. In ... Read More

Hardy-Ramanujan Theorem

Rinish Patidar
Updated on 28-Aug-2023 15:27:05

134 Views

The Hardy−Ramanujan Theorem states that the number of distinct prime factors of any natural number N will be approximately equal to the value of $\mathrm{\log(\log N)}$ for most of the cases. For example, let’s consider N to be 1000. The number of distinct prime factors of 15 are 2 and 5 i.e. 2 distinct prime factors. The value of $\mathrm{\log_{e}(\log_{e}(1000))}$ is equal to 1.932 which is approximately equal to 2. The Hardy−Ramanujan theorem is proved in the above case. Since the theorem states that the number of distinct prime factors will be approximately equal to $\mathrm{\log(\log(N))}$ for most of ... Read More

Advertisements