Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Mock_exam_2_Task_1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = int.Parse(Console.ReadLine());
- int sum = 0;
- int multiplication = 1;
- bool isContainsOne = false;
- while (number != 0)
- {
- isContainsOne = false;
- int currDigit = number % 10;
- sum += currDigit;
- multiplication *= currDigit;
- if (currDigit == 1)
- {
- isContainsOne = true;
- }
- number /= 10;
- }
- if (isContainsOne)
- {
- multiplication += 1;
- }
- if (multiplication > sum)
- {
- Console.WriteLine(multiplication);
- }
- else
- {
- Console.WriteLine(sum);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement