# Prime numbers

• 02-29-2012
GolDRoger
Prime numbers
Code:

```#include<stdio.h> int main() {   int count = 0;   int num_limit = 100;     int factor = 1;   int result = 0;   for(num_limit = 100; count <= num_limit; count++)   {       if(count == 2)       {         printf("%d\n", count);       }             if(count == 3)       {         printf("%d\n", count);       }             if(count % 2 != 0 && count % 3 != 0)       {         while(factor <= count) // Trying to exclude perfect squares by finding the factors of number(count)         {             if(factor % count == 0) // Findin factors of number(count)             {               int fact_res = factor * factor; // fact_res the result of multiplying a factor by itself               if(fact_res == count)               {                   result++; // if fact_res is equal to number(count) then number is a perfect square               }            // then result is increased by 1             }                         factor++;         }                 if(result == 0)         {             printf("%d\n", count); // if result is greater than 0 then number is not a prime number         }       }   }   return 0; }```