Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C++ Compiler.
  4. Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include"stdio.h"
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15. int num;
  16. bool prime=0;
  17. scanf("%d",&num);
  18. int line=0;
  19. for (int n=2;n<num;n++)
  20. {
  21. prime=1;
  22. for(int i=2;i<n/2;i++)
  23. {
  24. if(n%i==0)
  25. {
  26. prime=0;
  27. break;
  28. }
  29. }
  30. if(prime)
  31. {
  32. line++;
  33. printf("%d ",n);
  34. if(line%5==0)
  35. printf("\n");
  36. }
  37. }
  38.  
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement