Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int CifrePrime(int n)
- {
- int s=0,prim,r,d,c;
- while(n!=0)
- {
- c=n%10;
- r=sqrt(c);
- prim=(c%2!=0 || c==2) && (c>1);
- for(d=3;d<=r && prim==1;d+=2)
- {
- if(c%d==0)
- {
- prim=0;
- }
- }
- if(prim==1)
- {
- s+=c;
- }
- n=n/10;
- }
- return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement