I would like to have a function f such that f(0) = 0 and f(x) = 1 for any x>0. I can compute f in the following way:(adsbygoogle = window.adsbygoogle || []).push({});

f(x) = (2*x+1)/2 - (2*x-1)/2 . Here the division is integer division. But if x=0, here we divide (2*0-1)/2 or -1/2, which is a problem. Because we do not have any number -1 here.

We can also compute f(x) as follows

f(x) = ((2*x+3) % 2*(x-1)+3)/2 . Here % is remainder. This is also a problem because we are doing something like x%y which is nonlinear. To be clear x%2 is allowed, but x%y is not allowed.

So, can anyone help me constructing such a function which is linear and over positive integer and all operation will be integer operation? Or can anyone tell me that it is not possible to construct f with such restriction?

I really appreciate any help.

NB: f simply checks weather any positive number is zero or not and return 0 if 0 ;else return -1.

Thanks a lot...

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Checking weather any positive number is zero or not

**Physics Forums | Science Articles, Homework Help, Discussion**