Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int pierwsza(int x)
- {
- int j;
- for(j=0;j<=x;j++)
- {
- if(x%j==0)
- {
- return 0;
- }
- }
- return 1;
- }
- void liczby_pierwsze()
- {
- int a, b, i ;
- printf("Podaj 2 liczby\n");
- scanf("%d",&a);
- scanf("%d",&b);
- if(b>a)
- {
- for(i=a;i<=b;++i)
- {
- if(pierwsza(i)==1)
- {
- printf("%d\n",i);
- }
- }
- }
- else
- printf("Pierwsza liczba musi byc mniejsza od drugiej\n");
- }
- int main(int argc, char *argv[]) {
- liczby_pierwsze();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement