program mencari bilangan prima

#include
#include
int prima(int bil){
int i;
for(i=2; i < bil;i++)
{
if(bil%i==0){
return(0);}}
return(1);}
int main(){
int jarak,i;

printf("Nama : afit miranto\n");
printf("NPM : G1D009001\n");
printf("Prodi: Teknik Elektro\n\n");
printf("program mencari bilangan prima \n");
printf("jarak bilangan yg diinginkan: ");
scanf("%d",&jarak);
printf("2");
for(i=3;i<=jarak;i++){
if(prima(i)){
printf(",%d",i);
}}}

Categories:

0 comments:

Post a Comment