Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool provjera(int);
- int main() {
- int brN;
- cout << "Unesite neki broj n: ";
- cin >> brN; // savrseni brojevi: 6, 28, 496 (source: wikipedia)
- if (provjera(brN) == true){
- cout << "Broj " << "je savrsen!" << endl;
- }
- else cout << "no";
- system("pause>0");
- return 0;
- }
- bool provjera(int broj) {
- int sum = 0;
- for (int i = 1; i< broj; i++) {
- if (broj%i == 0)
- sum += i;
- }
- if (sum == broj){
- return true;
- }
- else
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement