a group of friends goes for dinner and gets bill of Rs 2400
. Two of them says that they have forgotten their purse so
remaining make an extra contribution of Rs 100 to pay up
the bill. Tell the no. of person in that group
Let 'x' be the number of perons in the group and let 'y' be
amount per head which they have to pay.
Then xy = 2400.
or y = 2400/x
Since two friends have forget the purse, x-2 persons should
share the total amount(2400).
If they share, they have to make an extra contribution of
Rs 100 to pay up the bill
That is x-2 persons should pay y+100 each
or (x-2)(y+100) = 2400
or y+100 = 2400/(x-2)
or y = 2400/(x-2) - 100
Therefore we have got two equations namely,
y= 2400/x and y = 2400/(x-2) - 100
Comparing these two, we get
2400/x = 2400/(x-2) - 100
Solving this we get
x^2 - 2x -48 = 0
or (x-8) (x+6) = 0
or x = 8 or x = -6
Since 'x' denote the number of persons, it should be
So, x = 8.
Ques--Input a number and then find the next higher number
such that for both the number (inputted and the next higher
in binary representation contains equal number os ones.
I want a solution in C/C++ language