Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
austinhutchen committed May 26, 2023
1 parent e330459 commit c7ffd50
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
23 changes: 23 additions & 0 deletions components/algo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,29 @@ uint b2hx(vector<bitset<8> > input, uint &size){
hx=b2hx(vect,max);
return vect;
}

bool is_prime(int n) {
if (n <= 1) {
return false;
}
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}

int nearest_prime(int n) {
int prime = 0;
for (int i = n-1; i >= 2; i--) {
if (is_prime(i)) {
prime = i;
break;
}
}
return prime;
}

vector<bitset<8> > load(){
ifstream in;
Expand Down
8 changes: 0 additions & 8 deletions components/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ class send {



int main()
{
for (int currentNum = 2; ; currentNum++) {
if (isPrime(currentNum)) {
std::cout << currentNum << " ";
}
}
}

int edit(int &num) {
int count = 1;
Expand Down
21 changes: 17 additions & 4 deletions components/testers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,28 @@ class tester {
cin >> needle;
cout << alg.strStr(stack, needle) << endl;
}
bool isPrime(int number)
{
for (int a = 2; a < number; a++) {
if (number % a == 0) {
bool is_prime(int n) {
if (n <= 1) {
return false;
}
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}

int nearest_prime(int n) {
int prime = 0;
for (int i = n-1; i >= 2; i--) {
if (is_prime(i)) {
prime = i;
break;
}
}
return prime;
}
void fio() {
// file i/o
string filename;
Expand Down

0 comments on commit c7ffd50

Please sign in to comment.