Spocoman

04. Sequence 2k+1

Nov 20th, 2021 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Sequence2k_1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int num = int.Parse(Console.ReadLine());
  10.             int k = 1;
  11.  
  12.             while (k <= num)
  13.             {
  14.                 Console.WriteLine(k);
  15.                 k = 2 * k + 1;
  16.             }
  17.         }
  18.     }
  19. }
  20.  
Add Comment
Please, Sign In to add comment