Advertisement
Filip13

deljiv brojevina od 1 do n

Oct 27th, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int k, n;
  7. cin >> k >> n;
  8.  
  9. bool deljivost = true;
  10. int i = 1;
  11.  
  12.  
  13. while ((i <= n) && deljivost == true) {
  14. if (k % i == 0) {
  15. deljivost = true;
  16. }
  17.  
  18. else {
  19. deljivost = false;
  20. }
  21.  
  22. i++;
  23. }
  24.  
  25.  
  26. if (deljivost == true) {
  27. cout << "da";
  28. }
  29.  
  30. else if (deljivost != true) {
  31. cout << "ne";
  32. }
  33. }
  34.  
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement