Sudhir sharma has Published 1149 Articles

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

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 10:53:23

351 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 ... Read More

Prime numbers and Fibonacci in C++

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 10:49:44

811 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 ... Read More

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

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 10:39:59

180 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 ... Read More

Prime String in C++

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 10:35:33

417 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 ... Read More

Prime Triplet in C++

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 10:33:02

348 Views

In this problem, we are given a number N. Our task is to print all prime triplets less than N.Prime triplet is a set of three prime numbers. That are of the form (p, p+2, p+6) or (p, p+4, p+6). All prime numbers are grouped according to the above triplets ... Read More

Primitive root of a prime number n modulo n in C++

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 10:29:48

1K+ Views

In this problem, we are given a prime number N. our task is to print the primitive root of prime number N modulo N.Primitive root of prime number N is an integer x lying between [1, n-1] such that all values of xk (mod n) where k lies in [0, ... Read More

Primorial of a number in C++

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 10:24:24

499 Views

In this problem, we are given a number n. Our task is to print its primorial number.Primorial number (Pn#) is a number that is the product of first n prime numbers.Primorial number is similar to factorial of a number n. The difference is that factorial can be any number but ... Read More

Print * in place of characters for reading passwords in C

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 10:20:11

637 Views

In this problem, we are given a string password. Our task is to print * in place of characters of the password.Let’s take an example to understand the problem, Input: password Output ********To solve this problem, we will traverse the password we have entered and print * in place of ... Read More

Print Kth least significant bit of a number in C++

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 10:17:46

427 Views

In this problem, we are given two numbers n and k. Our task is to print the kth least significant bit of the number n.Let’s take an example to understand the problemInput: n = 12 , k = 3 Output 1 Explanation: Let’s see the binary representation of n: 12 ... Read More

Print 1 2 3 infinitely using threads in C

sudhir sharma

sudhir sharma

Updated on 03-Feb-2020 10:15:24

486 Views

Here, we have to print 1 2 3 sequences repeatedly infinite number of times using threads in the c programming language.Let’s see the sample output that we want from our code, 1 2 3 1 2 3 1 2 3 1 2 3For this, we will have to use three ... Read More

Advertisements