Check if a number is Flavius Number | Java implementation of the above approach ; 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
class GFG { static boolean Survives ( int n ) { for ( int i = 2 ; ; i ++ ) { if ( i > n ) return true ; if ( n % i == 0 ) return false ; n -= n / i ; } } public static void main ( String [ ] args ) { int n = 17 ; if ( Survives ( n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }