fork download
  1. import java.util.*;
  2.  
  3. class Ideone
  4. {
  5. static int sumOfDigits( int N ){
  6. int sum = 0,mult =1;
  7. while( N>0 ){
  8. int digit = N%10;
  9. sum = sum+digit*mult;
  10. N = N/10;
  11. mult= mult*2;
  12. }return sum;
  13. }
  14. public static void main (String[] args) throws java.lang.Exception
  15. {
  16. int result = sumOfDigits( 1010 );
  17. System.out.println(result);
  18. }
  19. }
  20.  
Success #stdin #stdout 0.08s 54704KB
stdin
Standard input is empty
stdout
10