Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.0 kB
1
Indexable
Never
 import java.util.*;


 // Compiler version JDK 11.0.2

 class Dcoder
 {
   public static void main(String args[])
   { 
     int oddsum=0;
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
    
    int originalNumber, remainder, result = 0, n = 0;

        originalNumber = number;

        for (;originalNumber != 0; originalNumber /= 10, ++n);

        originalNumber = number;

        for (;originalNumber != 0; originalNumber /= 10)
        {
            remainder = originalNumber % 10;
            result += Math.pow(remainder, n);
        }

        if(result == number)
            {
        originalNumber = number;
    int digit, sum = 0;
    
    while(number != 0)
    {
      digit = number % 10;   
      
      if(digit % 2 == 0)
        sum = sum + digit;
        else oddsum=oddsum+digit;
              
      number = number / 10;
    }
    System.out.println(sum);
            }
        else
        { 
          System.out.print(oddsum);
          
        }
              
   }
 }