If all conditions are met , it proves Midy 's theorem
void Midys ( string str , int n ) { int l = str . length ( ) ; int part1 = 0 , part2 = 0 ; if ( ! isPrime ( n ) ) { cout << " 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 [ i ] - '0' ) ; part2 = part2 * 10 + ( str [ l / 2 + i ] - '0' ) ; } cout << part1 << " ▁ + ▁ " << part2 << " ▁ = ▁ " << ( part1 + part2 ) << endl ; cout << " Midy ' s ▁ theorem ▁ holds ! " ; } else { cout << " The ▁ repeating ▁ decimal ▁ is ▁ of ▁ odd ▁ length ▁ " << " thus ▁ Midy ' s ▁ theorem ▁ is ▁ not ▁ applicable " ; } }