Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. int n, m, k = 0, broj;
  2.             Console.Write("Unesite n = ");
  3.             n = int.Parse(Console.ReadLine());
  4.             Console.Write("Unesite m = ");
  5.             m = int.Parse(Console.ReadLine());
  6.  
  7.             for (int i = n; i <= m; i++)
  8.             {
  9.                 broj = i;
  10.                 if (broj == 1)
  11.                 {
  12.                     k++;
  13.                 }
  14.                 for (int j = 2; j <= i; j++)
  15.                 {
  16.                     while (broj % j == 0)
  17.                     {
  18.                         broj = broj / j;
  19.                         k++;
  20.                     }
  21.                     if (broj == 1)
  22.                     {
  23.                         break;
  24.                     }
  25.                 }
  26.             }
  27.  
  28.             Console.WriteLine("Broj prostih cinilaca je " + k);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement