terminator891

Prime number

Aug 24th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. void ithprime(unsigned int input)
  2. {
  3.     unsigned int count,ans,result; //storage
  4.     unsigned int i,j;
  5.     count=0;
  6.     i=2;
  7.  
  8.         while(1)
  9.         {
  10.             for(j=2;j<=i;j++)
  11.             {
  12.                 if(i==j)
  13.                 {
  14.                     count=count+1;
  15.                     break;
  16.                 }
  17.                 if(i%j==0)
  18.                 {
  19.                     break;//Not a prime number
  20.                 }
  21.             }
  22.  
  23.  
  24.             if(count==input)
  25.             {
  26.                 result=i;
  27.                 break;
  28.             }
  29.              i++;
  30.         }
  31.  
  32.  
  33.     printf("%u\n",result);
  34. }
Add Comment
Please, Sign In to add comment