Skip to content

Instantly share code, notes, and snippets.

@Khuirul-Huda
Last active October 12, 2023 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Khuirul-Huda/3146222b0768abe491fe84351554189c to your computer and use it in GitHub Desktop.
Save Khuirul-Huda/3146222b0768abe491fe84351554189c to your computer and use it in GitHub Desktop.
isPrime.cpp V2
#include <iostream>
using namespace std;
bool isPrima(int number) {
if (number <= 1 ) {
return false;
}
for (int i = 2; i < number; i++) {
if ((number % i) == 0) {
return false;
}
}
return true;
}
int main() {
cout << "Nama: Muhammad Khuirul Huda" << endl;
cout << "NIM: 23041300xx" << endl;
cout << "Kelompok: 15. Clion" << endl;
cout << "Prodi: Teknik Informatika" << endl;
int number;
cout << "Masukkan Nilai:";
cin >> number;
if (isPrima(number)) {
cout << "Bilangan " << number << " adalah bilangan prima";
} else {
cout << "Bilangan " << number << " bukan bilangan prima";
}
}
@MUHAMMADFIRDASATRIA
Copy link

mantap bang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment