December SPECIAL! For a limited time only. Get 20% discount on a LIFETIME PRO account!Want more features on Pastebin? Sign Up, it's FREE!
tweet
Guest

Untitled

By: a guest on Sep 18th, 2015  |  syntax: C  |  size: 0.43 KB  |  views: 63  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print  |  QR code  |  clone
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char *argv[])
  4. {
  5.         int primes[50];
  6.         int i = 0;
  7.         int x = 0;
  8.         int not_prime = 0;
  9.         int num = 0;
  10.         for(i = 1; i < 100; i++) {
  11.  
  12.                 not_prime = 0;
  13.  
  14.                 for(x = 1; x < num; x++) {
  15.                         if(i % primes[x] == 0) {
  16.                                 not_prime = 1;
  17.                         }                      
  18.                 }
  19.  
  20.                 if(not_prime == 0) {
  21.                         primes[num] = i;
  22.                         num++;
  23.                 }
  24.  
  25.         }
  26.  
  27.         i = 1;
  28.  
  29.         for(i = 1; i < num; i++) {
  30.                 printf("%d ",primes[i]);
  31.         }
  32.  
  33.         return 0;
  34. }
clone this paste RAW Paste Data
Top