Krasimir_Slavov

Untitled

Oct 24th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Loop_Combination
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.  
  15.             int counter = 0;
  16.             for (int x1 = 0; x1 <= n; x1++)
  17.             {
  18.                 for (int x2 = x1; x2 <= n; x2++)
  19.                 {
  20.                     for (int x3 = x2; x3 <= n; x3++)
  21.                     {
  22.                         for (int x4 = x3; x4 <= n; x4++)
  23.                         {
  24.                             for (int x5 = x4; x5 <= n; x5++)
  25.                             {
  26.                                 n = x1 + x2 + x3 + x4 + x5;
  27.                                 counter++;
  28.                             }
  29.                         }
  30.                     }
  31.                 }
  32.             }
  33.             Console.WriteLine(counter);
  34.  
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment