Skip to content
Snippets Groups Projects
Commit 15c0ccaa authored by Jean-Baptiste Priez's avatar Jean-Baptiste Priez
Browse files

JB: exo wims math

parent 5b16ef47
No related branches found
No related tags found
No related merge requests found
#include <iostream>
using namespace std;
void Blaise(int &acc, int n) {
acc = n * (n+1) / 2;
}
int main() {
int somme = 0;
Blaise(somme, 8);
cout << "Blaise dit que la somme est de : " << somme << endl;
return 0;
}
#include <iostream>
#include <math.h>
using namespace std;
bool premier(int n) {
if (n % 2 == 0) return true;
for (int d = 3; floor(sqrt(n)+1); d=d+2)
if (n % d == 0)
return false;
return true;
}
int main() {
if (premier(21))
cout << "Prim" << endl;
else
cout << "Pas Prim" << endl;
return 0;
}
#include <iostream>
using namespace std;
void Blaise(int &acc, int n) {
acc = n * (n+1) / 2;
}
int main() {
int somme = 0;
Blaise(somme, 8);
cout << "Blaise dit que la somme est de : " << somme << endl;
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment