Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
618 B
3
Indexable
Never
	Scanner in = new Scanner(System.in);

		int n = in.nextInt();

		int a = n;

		int q=n;

		int x=0;

		while(n!=0) {

			n/=10;

			x++;

		}

		int sum=0;

		while(a!=0) {

			int res = a%10;

			sum+=Math.pow(res, x);

			a/=10;

		}

		if(q==sum) {


			int se=0;

			while(q!=0) {

				int r=q%10;

				if(r%2==0) {

					se+=r;

				}

				q/=10;

			}

			System.out.println(se);			

		}else {


			int so=0;

			while(q!=0) {

				int r=q%10;

				if(r%2!=0) {

					so+=r;

				}

				q/=10;

			}

			System.out.println(so);

		}