Prime String | C # program to find if string is a Prime or not ; Function that checks if sum is prime or not ; Corner cases ; This is checked so that we can skip middle five numbers in below loop ; Driver code
using System ; class GFG { public static bool isPrimeString ( string str ) { int len = str . Length , n = 0 ; for ( int i = 0 ; i < len ; i ++ ) { n += ( int ) str [ i ] ; } if ( n <= 1 ) { return false ; } if ( n <= 3 ) { return true ; } if ( n % 2 == 0 n % 3 == 0 ) { return false ; } for ( int i = 5 ; i * i <= n ; i = i + 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } public static void Main ( string [ ] args ) { string str = " geekRam " ; if ( isPrimeString ( str ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }