Advertisement
ss3434

prosto 4islo

Oct 28th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Proba2Prime
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int num1, num2, num3, num4;
  10.  
  11. num1 = int.Parse(Console.ReadLine());//starting number
  12. num2 = int.Parse(Console.ReadLine());//ending number
  13.  
  14. for ( num3 = num1; num3 <= num2; num3++)
  15. {
  16. num4 = 0;//filter for non-Prime numbers(moje i bool izdraz)
  17. for (int i = 2; i <=num3/2 ; i++)// where the magic happens :D
  18. {
  19. if (num3%i==0)//i zapochva ot 2 znachi ako chetno vliza, vkliuchva filtyra i izliza.
  20. {
  21. num4++;
  22. break;
  23. }
  24. }
  25. if (num4 ==0 && num3!=1)// ako ima filtyr ne vliza
  26. {
  27. Console.WriteLine(num3);//prime numebr!
  28. }
  29. }
  30.  
  31.  
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement