Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- unsigned int n_from, n_to,n[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101},prime,riza,kr;
- int main(void)
- {
- //--------------------------------------------------------
- //---------------------------------------------------------
- FILE * in = fopen ("function.in", "r");
- FILE * out = fopen ("function.out", "w");
- fscanf (in , "%d %d", &n_from, &n_to);
- //--------------------------------------------------------
- //---------------------------------------------------------
- if (n_from > n_to)
- {
- kr=n_from;
- n_from=n_to;
- n_to=kr;
- }
- n_from++;
- //--------------------------------
- if (n_from == 2)
- n_from++;
- while (n_from < n_to)
- {
- riza=sqrtf(n_from);
- if(prime==1)
- goto kalo_loop;
- //--------------------------------------------------------------------------------
- kr=0;
- for (n[kr]; n[kr] <= riza; kr++) // check if prime
- {
- if ((n_from % n[kr]) == 0)
- {n_from--;
- goto loop;
- }
- }
- //--------print----------------------------------------
- fprintf(out,"%d", n_from);
- prime=1;
- goto loop;
- //-------------------------------------------------------------------------------------------
- //-----------------------------------------------------------------------------------------
- kalo_loop:
- kr=0;
- for (n[kr]; n[kr] <= riza; kr++) // check if prime
- {
- if ((n_from % n[kr]) == 0)
- goto loop;
- }
- //----------print---------------
- //----------print----------------
- fprintf(out," %d", n_from);
- loop:
- n_from+=2;
- }
- if (prime == 1)
- fprintf(out,"\n");
- end:
- fclose(in); fclose(out);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement