Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- bool prost(int broj)
- {
- int counter(0);
- for(int i = 1; i<=broj; i++)
- {
- if(broj % i == 0)
- counter++;
- }
- if(counter == 2)
- return true;
- return false;
- }
- int nti_prost(int indeks)
- {
- int counter(0), pocetni(2);
- while(counter < indeks)
- {
- if(prost(pocetni))
- counter++;
- pocetni++;
- }
- return pocetni-1;
- }
- int main()
- {
- int indeks;
- std::cout << "Unesite indeks: " << std::endl;
- std::cin >> indeks;
- std::cout << "Nti prosti broj je: " << nti_prost(indeks);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment