Given a series of integers from 1 to infinity and a number N.
The task is to remove every (i + 1)-th element from the remaining series at every i-th iterations and find that the given number N exists in the series or not.
Numbers in the Flavius Sieve are called Flavius Numbers.
Flavius sieve starts with the natural numbers and keep repeating the below step:
At the k-th sieving step, remove every (k+1)-st term of the sequence remaining of N natural numbers after the (k-1)-st sieving step.
For Example: 1, 3, 7, 13, 19, 27, 39, 49,
Input: N = 17
Series after i-th iterations
1). 1, 3, 5, 7, 9, 11, 13, 15, 17, …
2). 1, 3, 7, 9, 13, 15, 19, 21, 25, …
3). 1, 3, 7, 13, 15, 19, 25, …
4). 1, 3, 7, 13, 19, 27, ….
Input: N = 3
- If the given number is even so the answer is simply “No”. Because in the first iteration all the even number has been eliminated from the series.
- Repeat this process.
Else remove the number of elements removed at 1st iteration i.e. (1/2)th the number and then check
if it is divisible by 3 the answered should be “No”, else subtract the numbers before it that were
removed i.e. (1/3)rd the number and so on.
- Repeat above step for all iterations until we get answer.
- Else remove the number of elements removed at 1st iteration i.e. (1/2)th the number and then check
Below is the implementation of the approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check if a number is divisible by all prime divisors of another number
- Program to check whether a number is Proth number or not
- Check if a number with even number of digits is palindrome or not
- Check if the number is a Prime power number
- Check if a number is a Krishnamurthy Number or not
- Check Whether a number is Duck Number or not
- Check if given number is Emirp Number or not
- Check whether a number is Non-hypotenuse number
- Check if a number is Triperfect Number
- Check if a given number is factorial of any number
- How to check if a given number is Fibonacci number?
- Check whether the given number is Euclid Number or not
- Check whether given number N is a Moran Number or not
- Check if a number is a Trojan Number
- Check if a number ends with another number or not
- Check whether a given number N is a Nude Number or not
- Check if a number is an Unusual Number or not
- Check if a number is a Mystery Number
- Check if a number is a power of another number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.