Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- unsigned long n,x,i,d,eprim,S=0,f;
- cout<<"n=";cin>>n;
- for (i=1;i<=n;i++)
- {
- cin>>x;
- f=2;eprim=1;
- while (1)
- {
- for (d=2;d<=sqrt(f)&&eprim;d++)
- if (f%d==0)
- eprim=0;
- if (eprim&&x%f==0)
- {
- S+=f;
- break;
- }
- f++;
- }
- }
- cout<<"S="<<S;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement