Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool prost(int x) {
- for (int j = 2; j < x; j++) {
- if (x%j == 0) {
- return false;
- }
- }
- return true;
- }
- int main() {
- // napišite program u kojem ćete omogućiti unos dva prirodna broja manja od 500 koji predstavljaju granice intervala
- int x = 0;
- int y = 0;
- int suma = 1;
- do {
- cout << "Molimo unesite dva broja manja od 500" << endl;
- cin >> x;
- cin >> y;
- } while (x >= 500 || y >= 500);
- //te pronaći i ispisati kojom cifrom/znamenkom završava umnožak svih prostih brojeva u zadanom intervalu uključujući granične vrijednosti.
- for (int i = x; i <= y; i++) {
- if (prost(i) == true) {
- suma *= i;
- }
- }
- cout << "Suma je" <<suma<< endl;
- system("pause>null");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement