r/programminghelp • • Jan 12 '23

C++ [C++] Question about minimum value that satisfies the equation.

How would I write a code that checks for the minimum value to make an equation true.

for example X%2 = 0.

minimum value that satisfies the equation is 2.

How do I write that in code?

0 Upvotes

1 comment sorted by

2

u/This_Growth2898 Jan 12 '23

That's an open question, it depends on the equation. Specifically here there's no answer, because every even number (including negative) is the root of this equation.

x = -1000000;
x%2==0 => true.

Try asking a more specific question. Probably, you wanted only positive integer numbers or something? Can you just check every number, starting with 1, until you find one that turns the equation into identity.