Last active
October 12, 2023 07:51
-
-
Save Khuirul-Huda/3146222b0768abe491fe84351554189c to your computer and use it in GitHub Desktop.
isPrime.cpp V2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mantap bang