If I have an odd number, how would I divide it in two and leave two integers, with the first being one more than the second. For instance 9 would produce 5 and 4?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The “smaller half” of
int xisx/2. The “bigger half” isx/2 + x%2orx - x/2.Note that “smaller” and “bigger” refer to the absolute value, so in the case of negative
x,bigger < smaller.Of course, if
xis always odd and positive, thenx%2will be1and the bigger half can also be computed asx/2 + 1.