fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool isPrime(int num) {
  5. for(int i = 2; i < num; i++)
  6. if(num%i == 0)
  7. return false;
  8. cout << "TES" << endl;
  9. return true;
  10. }
  11.  
  12. int main() {
  13. /*
  14. // Refresher percabangan perulangan
  15. int angka1, angka2;
  16. angka1 = 10;
  17. angka2 = 0;
  18. for(int i = 0; i < angka1; i++) {
  19. if(i == 5)
  20. continue;
  21. angka2 += i;
  22. }
  23. cout << angka2 << endl;
  24. // 0+1+2+3+4+6+7+8+9 = 40
  25.  
  26. // Array
  27. int array[10]; // 0--9
  28. array[0] = 100;
  29. array[1] = 150;
  30. for(int i = 0; i < 10; i++) {
  31. array[i] = 0;
  32. }
  33. */
  34.  
  35. // Fungsi & Rekursi
  36. if(isPrime(37))
  37. cout << "37 = PRIMA" << endl;
  38. else
  39. cout << "37 = KOMPOSIT" << endl;
  40.  
  41. if(isPrime(36))
  42. cout << "36 = PRIMA" << endl;
  43. else
  44. cout << "36 = KOMPOSIT" << endl;
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
TES
37 = PRIMA
36 = KOMPOSIT