Sudhir sharma has Published 1206 Articles

Print all possible sums of consecutive numbers with sum N in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:30:24

411 Views

In this problem, we are given a positive integer N and we have to print the sequence of all possible consecutive numbers with a sum equal to N.Let’s take an example to understand the problem, Input: N = 15 Output: 1 2 3 4 5 7 8A simple solution to ... Read More

Print all possible words from phone digits in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:23:51

702 Views

In this problem, we are given a number and we have to print all words that can be formed by pressing those words in an old fashioned mobile keyboard.We are quite familiar with the QWERTY keyboard style that we use today. But before the invention of QWERTY keypad phones were ... Read More

Print all prime factors and their powers in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:16:29

513 Views

In this problem, we are given a number N, and we have to find all unique prime factors and their powers that divide the number.Let’s take an example to understand the topic −Input: 55 Output: 5 power 1 11 power 1Explanation −55 is divisible by 5 and 11.To solve this ... Read More

Print all prime numbers less than or equal to N in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:13:55

827 Views

In this problem, we are given a number N and we have to print all prime numbers less than or equal to N.Let’s take an example to understand the topic better −Input: 10 Output: 2 3 5 7A prime number is a number that can be divided by only one ... Read More

Print all Prime Quadruplet of a number less than it in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:12:58

110 Views

In this problem, we are given a positive integer N, and we have to print all prime quadruplet less than or equal to n.Prime quadruplets are the set of four prime numbers calculated as {p, p+2, p+6, p+8}. Example − 5 7 11 13.Let’s take an example to understand the ... Read More

Print all Proth primes up to N in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:09:28

98 Views

In this problem, we are given an integer N and we have to print all proth prime numbers less than or equal to N.Proth Prime NumberA proth prime number is a positive integer whose value can be represented as n = k* 2n + 1. where k is an odd ... Read More

Print all root to leaf paths with there relative positions in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:07:39

94 Views

In this problem, we are given a binary tree. And we have to print all the paths from the root to the leaf of the tree. Also, add underscore “_” to show the relative positions of the nodes.Let’s take an example to understand the topic better −Input −Output −_ _ ... Read More

Print all safe primes below N in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:04:32

82 Views

In this problem, we are given an integer N and we have to print all safe prime number whose values are less than N.A safe prime number is a prime number which can be represented as [(2*p)- 1] where p is also a prime number.Examples − 5[(2*2) +1] , 7[(2*3)+1].Let’s ... Read More

Print all sequences of given length in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:02:28

597 Views

In this problem, we are given two integer values, k, and n. And we have to print all the sequences of length k from numbers from 1 to n in sorted order.Let’s take an example to understand the topic −Input:k = 2 ; n = 3 Output: 1 1 1 ... Read More

Print all sequences starting with n and consecutive difference limited to k in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:01:29

78 Views

In this problem, we are given three variables n, s, and k and we have to print all the possible sequences that start with the number n and length s having the absolute difference between consecutive elements less than k.Let’s take an example to understand the topic better −Input: n ... Read More

Advertisements