If all conditions are met , it proves Midy 's theorem
static void Midys ( String str , int n ) { int l = str . length ( ) ; int part1 = 0 , part2 = 0 ; if ( ! isPrime ( n ) ) { System . out . print ( " Denominator ▁ is ▁ not ▁ prime , ▁ " + " thus ▁ Midy ' s ▁ theorem ▁ is ▁ not ▁ " + " applicable " ) ; } else if ( l % 2 == 0 ) { for ( int i = 0 ; i < l / 2 ; i ++ ) { part1 = part1 * 10 + ( str . charAt ( i ) - '0' ) ; part2 = part2 * 10 + ( str . charAt ( l / 2 + i ) - '0' ) ; } System . out . println ( part1 + " ▁ + ▁ " + part2 + " ▁ = ▁ " + ( part1 + part2 ) ) ; System . out . print ( " Midy ' s ▁ theorem ▁ holds ! " ) ; } else { System . out . print ( " The ▁ repeating ▁ decimal ▁ is ▁ " + " of ▁ odd ▁ length ▁ thus ▁ Midy ' s ▁ " + " theorem ▁ is ▁ not ▁ applicable " ) ; } }