Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int najwiecej_dzielnikow(int a, int b){
  4. int index;
  5. int ilosc_dzielnikow;
  6. int ilosc_dzielnikow_max = 0;
  7. for(int i=a; i<=b; i++){
  8. ilosc_dzielnikow=0;
  9.  
  10. for(int j=1; j<=i; j++){
  11.  
  12. if(i % j == 0){
  13.  
  14. ilosc_dzielnikow++;
  15. }
  16. }
  17.  
  18. if(ilosc_dzielnikow > ilosc_dzielnikow_max){
  19. ilosc_dzielnikow_max = ilosc_dzielnikow;
  20. index = i;
  21. }
  22. }
  23. return index;
  24. }
  25.  
  26. using namespace std;
  27.  
  28. int main()
  29. {
  30. int a, b;
  31. cin>>a;
  32. cin>>b;
  33. int result = najwiecej_dzielnikow(a,b);
  34. std::cout <<"Result:"<< result << std::endl;
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement