fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int a[]={2,6},b[]={24,36},nums=0,i,j,m,n;
  7. n=2;
  8. m=2;
  9. for(i=1;i<=100;i++)
  10. {
  11. //first loop for checking common multiples of a[]
  12. j=0;
  13. while(j<n && i%a[j]==0)
  14. j++;
  15.  
  16. //after getting common multiples, checking if they are multiple of b[]
  17. if(j==n)
  18. {
  19. j=0;
  20. while(j<m && b[j]%i==0)
  21. j++;
  22.  
  23. if(j==m)
  24. nums++;
  25. }
  26. }
  27. cout<<"\nResult: "<<nums;
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
Result: 2