Senin, 05 Maret 2012

progam untuk mengetahui bilangan prima/bukan

#include <stdlib.h>
#include <stdio.h>
#include <iostream>

using namespace std;
      main()
      {
           
      int w,j,count=0;      
      cout<<"\nMasukkan Sebuah Angka : ";   
      cin>>w;
      for(j=2;j<=w/2;j++)
     
      {
         if(w%j==0)      
         count++;
       }
      
      if(count>0 || w<2)   
         cout<<w<<" Bukan Bilangan Prima\n";
      else cout<<w<<" Adalah Bilangan Prima\n";
        
    system("pause");
    return(0);
}

0 komentar:

Posting Komentar

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More