Advertisement
dragonbs

Combinations

Oct 23rd, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03.Combinations
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int magicNumber = int.Parse(Console.ReadLine());
  10.             int combinations = 0;
  11.  
  12.             for (int firstNumber = 0; firstNumber <= magicNumber; firstNumber++)
  13.             {
  14.                 for (int secondNumber = 0; secondNumber <= magicNumber; secondNumber++)
  15.                 {
  16.                     for (int thirdNumber = 0; thirdNumber <= magicNumber; thirdNumber++)
  17.                     {
  18.                         if (firstNumber + secondNumber + thirdNumber == magicNumber)
  19.                         {
  20.                             combinations++;
  21.                         }
  22.                     }
  23.                 }
  24.             }
  25.  
  26.             Console.WriteLine(combinations);
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement