Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace GameOfNumbers
- {
- class GameOfNumbers
- {
- static void Main(string[] args)
- {
- var n = int.Parse(Console.ReadLine());
- var m = int.Parse(Console.ReadLine());
- var magicalNumber = int.Parse(Console.ReadLine());
- var sum = 0;
- var combinations = 0;
- for (int i = n; i <= m; i++)
- {
- for (int j = n; j <= m; j++)
- {
- combinations++;
- if (i + j == magicalNumber)
- {
- Console.WriteLine($"Number found! {j} + {i} = {magicalNumber}");
- return;
- }
- }
- }
- Console.WriteLine($"{combinations} combinations - neither equals {magicalNumber}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement