Find all the strange number from 1 to N using C programming!
#include <stdio.h>
int main(){
int n,i,j,m,f;
scanf("%d",&n);
for(i=1;i<=n;i++){
f = 0;
for(j=i;j>0;j/=10){
m = j % 10;
if(m!=2 && m!=3 && m!=5 && m!=7){
f = 1;
break;
}
}
if(f==0){
printf("%d is a strange number\n",i);
}
}
return 0;
}
Comments
Post a Comment