Advertisement
edutedu

vr 11 pr 4

Dec 2nd, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int f(int x)
  5. {
  6. int i, sum=0;
  7. for(i=1; i<=x; i++)
  8. if(x%i==0)
  9. sum=sum+i;
  10. return sum;
  11. }
  12. int main()
  13. {
  14. int x, n, i, ct=0, a[100];
  15. cin>>x;
  16. cout<<"Suma este: "<<f(x)<<endl;
  17. cin>>n;
  18. for(i=0; i<n; i++)
  19. cin>>a[i];
  20. for(i=0; i<n; i++)
  21. {
  22. if(f(a[i])==a[i]+1)
  23. ct++;
  24. }
  25. cout<<ct;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement