SHARE
TWEET

bilangan prima

Anastasiaberlianna Nov 21st, 2019 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5.  
  6.  int bilangan, angka, stat;
  7.  printf("Masukkan bilangan: ");
  8.  
  9.  scanf("%d", &bilangan);
  10.  
  11.  
  12.  
  13.  if(bilangan <= 1) {
  14.  
  15.   printf("Masukkan angka lebih dari 1.");
  16.  
  17.  }else{
  18.  
  19.   if(bilangan == 2){
  20.  
  21.    printf("ya", bilangan);
  22.  
  23.   }else{
  24.  
  25.    for(angka=2; angka<bilangan; angka++){
  26.  
  27.     if(bilangan %angka == 0){
  28.  
  29.      stat = 0;
  30.  
  31.      break;
  32.  
  33.     }else{
  34.  
  35.      stat = 1;
  36.  
  37.     }
  38.  
  39.    }
  40.  
  41.  
  42.  
  43.    if(stat == 0){
  44.  
  45.     printf("tidak", bilangan);
  46.  
  47.    }else{
  48.  
  49.     printf("ya", bilangan);
  50.  
  51.    }
  52.  
  53.   }
  54.  
  55.  }
  56.  
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top