fork download
  1. #include <math.h>
  2. #include <stdio.h>
  3.  
  4. int main() {
  5. int maks;
  6. scanf("%d", &maks);
  7.  
  8. for (int i = 2; i <= maks; i++) {
  9. int prima = 1;
  10. for (int j = 2; j <= sqrt(i); j++) {
  11. if (i % j == 0) {
  12. prima = 0;
  13. break;
  14. }
  15. }
  16.  
  17. if (prima) {
  18. printf("*");
  19. } else {
  20. printf("%d", i);
  21. };
  22. if (i + 1 <= maks)
  23. printf(" ");
  24. }
  25. }
Success #stdin #stdout 0s 5276KB
stdin
10
stdout
* * 4 * 6 * 8 9 10