Commit a25a4920 authored by Tobias.Allrich's avatar Tobias.Allrich
Browse files

Added example for prim tests

parent d85680eb
#include <iostream>
bool is_prim_rec(int n, int t = 2)
{
if(n % t == 0) return false;
if(t == n / 2) return true;
return is_prim_rec(n, t+1);
}
bool is_prim_im(int n)
{
for(int i = 2; i < n / 2; i++)
{
if(n % i == 0) return false;
}
return true;
}
using namespace std;
int main()
{
cout<<is_prim_rec(21)<<"\n"<<is_prim_im(21);
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment