Sudhir sharma has Published 1148 Articles

Prime numbers and Fibonacci in C++

sudhir sharma

sudhir sharma

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

840 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

205 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

446 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

372 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

524 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

662 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

452 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

527 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

Print 2-D co-ordinate points in ascending order followed by their frequencies in C++

sudhir sharma

sudhir sharma

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

218 Views

In this problem, we are given 2 arrays x[] , y[] such that (x, y) gives a cordinate of a point in 2D plane. Our task is to print all points along with their frequencies of occurence.Let’s take an example to understand the problemInput: x[]={0, 1, 1, 0, 0} ; ... Read More

Advertisements