Advertisement
Guest User

Problem of the Week w/ C#

a guest
Feb 22nd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. int NineCount = 0;
  2.             int HowManyBeeps = 0;
  3.             while (NineCount < 300)
  4.             {
  5.                 for (int i = 0; i < 2000; i++)
  6.                 {
  7.                     if (i.ToString().Contains("9"))
  8.                     {
  9.                         NineCount++;
  10.                         HowManyBeeps = i - NineCount;
  11.                     }
  12.                     else if (i % 9 == 0)
  13.                     {
  14.                         NineCount++;
  15.                         HowManyBeeps = i - NineCount;
  16.                     }
  17.                     else if (!i.ToString().Contains("9") && i % 9 == 0)
  18.                     {
  19.                         NineCount++;
  20.                         HowManyBeeps = i - NineCount;
  21.                     }
  22.                 }
  23.             }
  24.             Console.WriteLine(HowManyBeeps);
  25.             Console.ReadLine();
  26.  
  27.             //You need to get up to 1552 for 300 beeps for all divisible by 9's for 300
  28.             // 1457 for all containing 9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement