Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main()
- {
- int n = Math.Abs(int.Parse(Console.ReadLine()));
- int result = GetMultipleOfEvenAndOdds(n);
- Console.WriteLine(result);
- }
- static int GetMultipleOfEvenAndOdds(int n)
- {
- int sumEven = GetSumOfEvenDigits(n);
- int sumOdd = GetSumOfOddDigits(n);
- return sumEven * sumOdd;
- }
- static int GetSumOfEvenDigits(int n)
- {
- int sum = 0;
- while( n > 0)
- {
- int lastDigit = n % 10;
- if(lastDigit %2 != 0)
- {
- sum = sum + lastDigit;
- }
- n /= 10;
- }
- return sum;
- }
- static int GetSumOfOddDigits(int n)
- {
- int sum = 0;
- while (n > 0)
- {
- int lastDigit = n % 10;
- if (lastDigit % 2 == 0)
- {
- sum = sum + lastDigit;
- }
- n /= 10;
- }
- return sum;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment