text: Ruth | C # implementation of the above approach ; Function to find prime divisors of all numbers from 1 to N ; if the number is prime ; add this prime to all it 's multiples ; Function to check Ruth - Aaron number ; Driver code
code: using System ; class GFG { static int Sum ( int N ) { int [ ] SumOfPrimeDivisors = new int [ N + 1 ] ; for ( int i = 2 ; i <= N ; ++ i ) { if ( SumOfPrimeDivisors [ i ] == 1 ) { for ( int j = i ; j <= N ; j += i ) { SumOfPrimeDivisors [ j ] += i ; } } } return SumOfPrimeDivisors [ N ] ; } static bool RuthAaronNumber ( int n ) { if ( Sum ( n ) == Sum ( n + 1 ) ) return true ; else return false ; } public static void Main ( ) { int N = 714 ; if ( RuthAaronNumber ( N ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }