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 ith iterations and find that the given number N exists in the series or not.
Flavius Number:
Numbers in the Flavius Sieve are called Flavius Numbers.
Flavius sieve starts with the natural numbers and keep repeating the below step:
At the kth sieving step, remove every (k+1)st term of the sequence remaining of N natural numbers after the (k1)st sieving step.
For Example: 1, 3, 7, 13, 19, 27, 39, 49,
Examples:
Input: N = 17
Output: N0Series after ith 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
Output: Yes
Approach:
 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:
C++
// C++ implementation #include <bits/stdc++.h> using namespace std; // Return the number is // Flavious Number or not bool Survives( int n) { int i; // index i starts from 2 because // at 1st iteration every 2nd // element was remove and keep // going for kth iteration for ( int i = 2;; i++) { if (i > n) return true ; if (n % i == 0) return false ; // removing the elements which are // already removed at kth iteration n = n / i; } } // Driver Code int main() { int n = 17; if (Survives(n)) cout << "Yes" << endl; else cout << "No" << endl; return 0; } 
Java
// Java implementation of the above approach class GFG { // Return the number is // Flavious Number or not static boolean Survives( int n) { // index i starts from 2 because // at 1st iteration every 2nd // element was remove and keep // going for kth iteration for ( int i = 2 ;; i++) { if (i > n) return true ; if (n % i == 0 ) return false ; // removing the elements which are // already removed at kth iteration n = n / i; } } // Driver Code public static void main(String[] args) { int n = 17 ; if (Survives(n)) System.out.println( "Yes" ); else System.out.println( "No" ); } } // This code is contributed by 29AjayKumar 
Python3
# Python3 implementation of # the above approach # Return the number is # Flavious Number or not def Survives(n) : # index i starts from 2 because # at 1st iteration every 2nd # element was remove and keep # going for kth iteration i = 2 while ( True ) : if (i > n) : return True ; if (n % i = = 0 ) : return False ; # removing the elements which are # already removed at kth iteration n  = n / / i; i + = 1 # Driver Code if __name__ = = "__main__" : n = 17 ; if (Survives(n)) : print ( "Yes" ); else : print ( "No" ); # This code is contributed by AnkitRai01 
C#
// C# implementation of the above approach using System; class GFG { // Return the number is // Flavious Number or not static bool Survives( int n) { // index i starts from 2 because // at 1st iteration every 2nd // element was remove and keep // going for kth iteration for ( int i = 2;; i++) { if (i > n) return true ; if (n % i == 0) return false ; // removing the elements which are // already removed at kth iteration n = n / i; } } // Driver Code public static void Main(String[] args) { int n = 17; if (Survives(n)) Console.WriteLine( "Yes" ); else Console.WriteLine( "No" ); } } // This code is contributed by PrinciRaj1992 
No
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a studentfriendly price and become industry ready.
Recommended Posts:
 How to check if a given number is Fibonacci number?
 Check if a number is a power of another number
 Check Whether a number is Duck Number or not
 Check if a number is divisible by all prime divisors of another number
 Check if given number is Emirp Number or not
 Check if a Mth fibonacci number divides Nth fibonacci number
 Check if a number with even number of digits is palindrome or not
 Program to check whether a number is Proth number or not
 Check whether the given number is Euclid Number or not
 Check if the given number is Ore number or not
 Check if a number is an Unusual Number or not
 Check if a number is a Trojan Number
 Check if a number is an Achilles number or not
 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 Triperfect Number
 Check whether a number is Nonhypotenuse number
 Check if a given number is factorial of any number
 Check if the number is a Prime power number
 Check whether given number N is a Moran Number or not
 Check whether a given number N is a Nude Number or not
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.