Convert to String to get sum of the cubes of its digits
String str = String . Join ( " " , N ) ; int sum = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { int val = ( int ) ( str [ i ] - '0' ) ; sum += val * val * val ; }