sudhir sharma

sudhir sharma

975 Articles Published

Articles by sudhir sharma

Page 55 of 98

Prime String in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 460 Views

In this problem, we are given a string. Our task is to print YES / NO based on is the sum of ASCII values of the characters of the string is prime or not.ASCII values are character encodingsPrime number is a number that is divisible only by the number itself and 1.Let’s take an example to understand the problem, Input: string = “Hello” Output:NoTo solve this problem, we will have to find the sum of ASCII values of all characters of the string. And store the sum in a variable and then check if the sum is a prime number ...

Read More

Prime points (Points that split a number into two primes) in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 238 Views

In this problem, we are given a number N. Our task is to print all prime points of the number otherwise print -1, if there is no prime point.Prime points are those index values which split the number into two prime numbers, one on the left and other on the right.Let’s take an example to understand the problemInput: 2359 Output: 1Explanation: on splitting the number at index 1. We will get 2 and 59 as two prime numbers.To solve this problem, we will check if there are left-right divisions possible for the number. If it’s valid, we will try all ...

Read More

Prime numbers and Fibonacci in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 883 Views

In this problem, we are given a number n. Our task is to print all prime and Fibonacci numbers less than or equal to n.Let’s take an example to understand the problemInput: n = 30 Output: 2 3 5 13ExplanationFibonacci numbers less than 30 are : 1 1 2 3 5 8 13 21.Out of these numbers, prime numbers are 2 3 5 13.To solve this problem, we have to check if all numbers of the Fibonacci series less than n is a prime number.For this, we will find all prime numbers less than or equal to n. And check ...

Read More

Prime numbers after prime P with sum S in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 433 Views

In this problem, we are given three numbers, sum S, prime P, and N. Our task is to find all N prime numbers greater than P whose sum is equal to S.Let’s take an example to understand our problemInput: N = 2, P = 5, S = 18 Output: 7 11 Explanation: Prime numbers greater than 5 : 7 11 13 Sum = 7 + 11 = 18To solve this problem, we have to find all prime numbers between P and S. And then find N prime numbers which sum up to S. For this we will use backtracking.Program to ...

Read More

Prime Number of Set Bits in Binary Representation in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 310 Views

In this problem, we are given two integers L and R. Our task to print the total numbers that have set bits counting to a prime number that is in between L to R.Let’s take an example to understand the problemInput: L = 7, R = 12 Output: 6 Explanation: 7 -> 111 , set bits = 2, prime number. 8 -> 1000 , set bits = 1, not prime number. 9 -> 1001 , set bits = 2, prime number 10 -> 1010 , set bits = 2, prime number 11 -> 1011, set bits = 3, prime number ...

Read More

Prime factors of LCM of array elements in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 255 Views

In this problem, we are given an array within the range 1

Read More

Prime factors of a big number in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 1K+ Views

In this problem, we are given an integer N

Read More

Prime Factor in C++ Program

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 13K+ Views

Prime Factor is a prime number which is the factor of the given number.Factor of a number are the numbers that are multiplied to get the given number.Prime Factorisation is the process of recursively dividing the number with its prime factors to find all the prime factors of the number.Example : N = 120 Prime factors = 2 5 3 Factorization : 2 * 2 * 2 * 3 * 5Some points to remember about prime factors of a numberSet of prime factors of a number is unique.Factorization is important in many mathematical calculations like divisibility, finding common denominators, etc.It’s ...

Read More

Primality test for the sum of digits at odd places of a number in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 164 Views

In this problem, we are given a number N. our task is to check whether the sum of digits at odd place of the number gives a prime number or not.Primality Test is the algorithm that is used to check whether the given number is prime or not.Let’s take an example to understand the problem, Input: 3425 Output: No Explanation: sum digits at odd place = 5 + 4 = 9, which is not a prime number.To solve this problem an easy approach would be adding all digits that are at odd places in the number and then checking whether ...

Read More

Primality Test in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 2K+ Views

In this problem, we are given a number N and our task is to check whether it is a prime number or not.Primality test s the algorithm that is used to check whether the given number is prime or not.Prime number is a number which can be divided by itself only. Example : 2, 3, 5, 7.Let’s take an example to understand our problem, Input: 11 Output: YesThere are multiple methods to check for primality test of a number.One simple method to check for primality is by checking the division of the number by all numbers less than N. If ...

Read More
Showing 541–550 of 975 articles
« Prev 1 53 54 55 56 57 98 Next »
Advertisements