machkovskitomche

funkcii/prostgore i prost(da se prasa)

Aug 12th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int prost(int n)
  5. {
  6.     int i;
  7.     for(i=2;i<=n/2;i++)
  8.     {
  9.         if(n%i==0)
  10.             return 0;
  11.     }
  12.     return 1;
  13. }
  14. int prost_gore(int n)
  15. {
  16.     n++;
  17. while (prost(n)==0)
  18.     {n++;}
  19. return n;
  20. }
  21. int main()
  22. {
  23.     int n,razlika;
  24.     printf("Vnesete go brojot:\t");
  25.     scanf("%d",&n);
  26.     razlika=(prost_gore(n)-n);
  27.     printf("Razlikata pomegju borjot %d i brojot %d iznesuva %d",prost_gore(n),n,razlika);
  28.     return 0;
  29. }//da prasam da mi se objasni uste malce
Add Comment
Please, Sign In to add comment