From fd5cc08a69a8acb5216623c5f97302d34bc72179 Mon Sep 17 00:00:00 2001 From: Charlotte Baptist <43832754+charBap@users.noreply.github.com> Date: Wed, 31 Oct 2018 17:55:24 -0400 Subject: [PATCH] Printing first n pernicious numbers Printing first n pernicious numbers using bit manipulation --- Bit Manipulation/perniciousNumber.cpp | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Bit Manipulation/perniciousNumber.cpp diff --git a/Bit Manipulation/perniciousNumber.cpp b/Bit Manipulation/perniciousNumber.cpp new file mode 100644 index 000000000..793c16902 --- /dev/null +++ b/Bit Manipulation/perniciousNumber.cpp @@ -0,0 +1,37 @@ +// CPP program to print first n pernicious numbers +#include +using namespace std; + +// function to check prime number +bool isPrime(int x) +{ + if (x < 2) + return false; + for (int i = 2; i < x; i++) { + if (x % i == 0) + return false; + } + return true; +} + +// Prints first n Pernicious numbers +void printPernicious(int n) +{ + for (int i=1,count=0; count