Venciity

[Jumpstart C#] loops demo - happy numbers

Jan 24th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. using System;
  2.  
  3. class HappyNumbers
  4. {
  5.     static void Main()
  6.     {
  7.         for (int a = 1; a <= 9; a++)
  8.         {
  9.             for (int b = 0; b <= 9; b++)
  10.             {
  11.                 for (int c = 0; c <= 9; c++)
  12.                 {
  13.                     for (int d = 0; d <= 9; d++)
  14.                     {
  15.                         if((a + b) == (c + d))
  16.                         {
  17.                             Console.WriteLine("{0}{1}{2}{3}", a, b, c, d);
  18.                         }
  19.                     }
  20.                 }
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment