Check if a number is Flavius Number | C ++ implementation ; Return the number is Flavious Number or not ; index i starts from 2 because at 1 st iteration every 2 nd element was remove and keep going for k - th iteration ; removing the elements which are already removed at kth iteration ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool Survives ( int n ) { int i ; for ( int i = 2 ; ; i ++ ) { if ( i > n ) return true ; if ( n % i == 0 ) return false ; n -= n / i ; } } int main ( ) { int n = 17 ; if ( Survives ( n ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }