Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Sum
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> arr = new List<int>();
- bool check = false; ;
- int multiplicationValues = 1;
- int inputNumber = int.Parse(Console.ReadLine());
- int endDigit = inputNumber % 10;
- if (inputNumber>=100 && inputNumber<=1000)
- {
- for (int a = 1; a <= 9; a++)
- {
- arr.Add(a);
- for (int b = 9; b >= a; b--)
- {
- arr.Add(b);
- for (int c = 0; c <= 9; c++)
- {
- arr.Add(c);
- for (int d = 9; d >= c; d--)
- {
- arr.Add(d);
- int sumArr = arr.Sum();
- for (int i = 0; i < arr.Count; i++)
- {
- multiplicationValues *= arr[i];
- }
- if (sumArr==multiplicationValues && endDigit==5)
- {
- Console.WriteLine("{0}{1}{2}{3}"
- ,arr[0],arr[1],arr[2],arr[3]);
- check = true;
- break;
- }
- int result = multiplicationValues / sumArr;
- int resultMod = inputNumber % 3;
- if (result==3 && resultMod==0)
- {
- Console.WriteLine("{0}{1}{2}{3}"
- ,arr[3],arr[2],arr[1],arr[0]);
- check = true;
- break;
- }
- if (check)
- {
- break;
- }
- multiplicationValues = 1;
- arr.RemoveAt(3);
- }
- if (check)
- {
- break;
- }
- multiplicationValues = 1;
- arr.RemoveAt(2);
- }
- if (check)
- {
- break;
- }
- multiplicationValues = 1;
- arr.RemoveAt(1);
- }
- if (check)
- {
- break;
- }
- multiplicationValues = 1;
- arr.RemoveAt(0);
- }
- if (check==false)
- {
- Console.WriteLine("Nothing found");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement