I am working on a mathmatical formula in which given a number, when you substitute the incognita of the formula for that number, you get another number. It looks sketchy, but the chart will demonstrate better: 1,3,5-3; 7,9-5; 11,13-7; 15,17-9; 19,21-11; The mathmatical formula for it is: (X-1)/2; if the modulus of the result of that operation and 2 is an even number, the result of the equation is (X+1)/2; if it is an odd number, the result of the formula will be (X+3)/2. Look: ((3-1)/2)%2 results in an odd number; therefore the result of the formula will be (3+3)/2, which results in 3. In each row of the chart, if you substitute X by a number in the chart, the result will be the number after the trace ("-"), with exception of 1. My concern is about conditional statements in Mathmatics. Well... in programming you have the so called loops and conditional statements, like if 3>6, do that; if z is superior to 3 and is different from 1, do that, and so on and so forth. My idea is to transform a set of conditional statements, or logical statements, like the one aforementioned, in a Mathmatical formula. So my problem is: 1- How can I express in a mathmatical formula: If the modulus of X is an odd number, make (X+3)/2; else (X+1)/2 2- If X is 1, return 3. If you are curious why I am asking that weird stuff, the answer is because I am trying to make a general math formula for the knigth shortest path problem. An example of logical statement in mathmatics is "choose the bigger number between x and y", that translated into mathmatical terms becomes 1/2*(x+y+absolute value of x-y). Thanks.