Advertisement
STANAANDREY

P1 ian

Jan 28th, 2019
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. unsigned long n,x,i,d,eprim,S=0,f;
  8. cout<<"n=";cin>>n;
  9.  
  10. for (i=1;i<=n;i++)
  11. {
  12.     cin>>x;
  13.     f=2;eprim=1;
  14.     while (1)
  15.     {
  16.      for (d=2;d<=sqrt(f)&&eprim;d++)
  17.         if (f%d==0)
  18.             eprim=0;
  19.  
  20.         if (eprim&&x%f==0)
  21.         {
  22.             S+=f;
  23.             break;
  24.         }
  25.         f++;
  26.     }
  27.  
  28. }
  29.  
  30. cout<<"S="<<S;
  31.  
  32.  return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement