Determining whether a number is a prime number

1 #include <stdio.h>
 2 #include < String .h>
 . 3  void the isPrime ( int Y)
 . 4  {
 . 5      // Analyzing 1 except itself and there is no other possible to make the divided digital 
. 6      int I;
 . 7      the while (Y <= . 1 )
 . 8      {
 . 9          the printf ( " digital not legal \ n- " );
 10          the printf ( " enter a number: " );
 . 11          Scanf ( " % D " , & Y);
 12 is      }
 13 is     IF (Y == 2 )
 14          the printf ( " % D is a prime number " , Y);
 15      for (I = 2 ; I <Y; ++ I)
 16      {
 . 17          IF (Y% I == 0 )
 18 is          {
 . 19              the printf ( " % D is not a prime number " , Y); BREAK ;
 20 is          }
 21 is          IF (I = Y- . 1 )
 22 is          {
 23 is              the printf ( " % D is a prime number " , Y); BREAK ;
24          }
 25      }
 26 is  }
 27  int main ()
 28  {
 29      int I;
 30      the printf ( " Enter a number: " );
 31 is      Scanf ( " % D " , & I);
 32      the isPrime (I);
 33 is      getchar ( );
 34 is      getchar ();
 35      return  0 ;
 36 }

 

Guess you like

Origin www.cnblogs.com/liugangjiayou/p/11747273.html