Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 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 Ukol01
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.Write("Vrchní hranice: ");
  14.             int max = int.Parse(Console.ReadLine());
  15.             Console.Write("Počet prvočísel: ");
  16.             int number = int.Parse(Console.ReadLine()), found=0;
  17.  
  18.             for(int i = max; found < number && i > 1; i--)
  19.             {
  20.                 bool prime = true;
  21.                 for(int q = i / 2; q > 1; q--)
  22.                 {
  23.                     if (i % q == 0) prime = false;
  24.                 }
  25.                 if (prime)
  26.                 {
  27.                     Console.WriteLine(i);
  28.                     found++;
  29.                 }
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement