Guest User

Untitled

a guest
Feb 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.  
  11.         static boolean prim(int szam)
  12.         {
  13.           if(szam == 1)
  14.               return false;
  15.          
  16.           for(int i = 2; i < szam; i++)
  17.           {
  18.               if(szam % i == 0)
  19.                   return false;
  20.           }
  21.          
  22.           return true;
  23.         }
  24.        
  25.         static void Main(string[] args)
  26.         {
  27.        
  28.            int[] tomb = new int[100];
  29.        
  30.            Random r = new Random();
  31.        
  32.            for (int i = 0; i < 100; i++)
  33.            {
  34.                tomb[i] = r.Next(1, 201);
  35.            }
  36.        
  37.            foreach (int elem in tomb)
  38.            {
  39.                if(prim(elem))
  40.                   Console.WriteLine(elem);
  41.            }
  42.              
  43.  
  44.  
  45.             Console.ReadKey();
  46.         }
  47.     }
  48. }
Add Comment
Please, Sign In to add comment