text: Position of n among the numbers made of 2 , 3 , 5 & 7 | C # Program position of n among the numbers made of 2 , 3 , 5 & 7 ; If number is 2 then it is on the position pos * 2 + 1 ; If number is 3 then it is on the position pos * 2 + 2 ; If number is 5 then it is on the position pos * 2 + 3 ; If number is 7 then it is on the position pos * 2 + 4 ; Driver code
code: using System ; class GFG { static int findpos ( String n ) { int pos = 0 ; for ( int i = 0 ; i < n . Length ; i ++ ) { switch ( n [ i ] ) { case '2' : pos = pos * 4 + 1 ; break ; case '3' : pos = pos * 4 + 2 ; break ; case '5' : pos = pos * 4 + 3 ; break ; case '7' : pos = pos * 4 + 4 ; break ; } } return pos ; } public static void Main ( String [ ] args ) { String n = "777" ; Console . WriteLine ( findpos ( n ) ) ; } }