Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- bool warunek(int x){
- if(x/10==0)return 1;
- while(x>10){
- if(x%10<(x/10)%10) return 0;
- x=x/10;
- }
- return 1;
- }
- void findPrimes(int a){
- bool* tab = malloc(a*sizeof(bool));
- tab[0]=0;
- tab[1]=0;
- for(int i=2;i<a;i++){
- tab[i]=1;
- }
- int j;
- for(int i=2;i*i<=a;i++){
- if(tab[i]){
- j=2*i;
- while(j<a){
- tab[j]=0;
- j+=i;
- }
- }
- }
- for(int i=0;i<a;i++){
- if(tab[i]){
- if(!warunek(i))
- tab[i]=0;
- }
- }
- for(int i=0;i<a;i++){
- if(tab[i])printf("%d\n",i);
- }
- }
- int main()
- { int a;
- scanf("%d",&a);
- findPrimes(a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement