Browse Source

Changed bool to int

remotes/origin/primzahl
Hendrik Sitzmann 11 months ago
parent
commit
5ece9a8b3e
  1. 1
      src/primzahl/main.c
  2. 9
      src/primzahl/primzahl.c
  3. 2
      src/primzahl/primzahl.h

1
src/primzahl/main.c

@ -1,7 +1,6 @@
#include "primzahl.h" #include "primzahl.h"
#include "../userinput.h" #include "../userinput.h"
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
int main() { int main() {
int minInput = 0; int minInput = 0;

9
src/primzahl/primzahl.c

@ -1,16 +1,15 @@
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
bool primzahl(int num) {
int primzahl(int num) {
//for the case zero or one //for the case zero or one
if (num <= 1) if (num <= 1)
return false;
return 0;
//checking if there are any other divider //checking if there are any other divider
for (int i = 2; i < num; i++) { for (int i = 2; i < num; i++) {
if (num % i == 0) if (num % i == 0)
return false;
return 0;
} }
//if none were found return true //if none were found return true
return true;
return 1;
} }

2
src/primzahl/primzahl.h

@ -1,6 +1,6 @@
#ifndef PRIMZAHL_H #ifndef PRIMZAHL_H
#define PRIMZAHL_H #define PRIMZAHL_H
bool primzahl(int num);
int primzahl(int num);
#endif #endif
Loading…
Cancel
Save