Help explain the Boolean functions

can someone explain me this algorithm into a mathematics language? (output programs)
thanks before.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
using namespace std;
bool FX (int x, int y);
int main()
{
	int i, j, count;
	i=2; j=2;
	count=0;
	while (i<=30) {
		if (!FX(i,j)) {
			cout << i <<
			count++;
		}
		i=i+3;
	}
	cout << count << endl;
	return 0;
}
bool FX (int x, int y) {
return (x%y == 0);
}
Last edited on
c++ asserts that 0 is false, and not zero is true.
% is modulus, or "remainder" of integer division.
== is equality operator (is this = to that?)

so
if x is evenly divisible by y, its true.

in math, roughly (all the symbol junk is a pain to insert)
if the remainder of x/y = 0 true else false


If the main program is doing anything more interesting than testing the function, I don't see it.
Last edited on
Topic archived. No new replies allowed.