Win a copy of Kotlin in Action this week in the Kotlin forum!
programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

[Easy]Divide my uncle's estate!!

Arjun Shastry
Ranch Hand
Posts: 1906
1
This was asked recently by one company during test:
When my Uncle in Bombay died recently ,he left a will, instructing his executors to divide his estate of Rs. 1,920,000 in this manner:
Every son should receive three times as a daughter,and that every daughter should get twice as much as their mother
What is my aunt's share?

Timothy Chen Allen
Ranch Hand
Posts: 161
Originally posted by Capablanca Kepler:

When my Uncle in Bombay died recently ,he left a will, instructing his executors to divide his estate of Rs. 1,920,000 in this manner:
Every son should receive three times as a daughter,and that every daughter should get twice as much as their mother
What is my aunt's share?

Assuming that A is the number of sons and B is the number of daughters, and "s" is the son's share, "d" the daughter's, and "m" the mother's, the formula for the mother's share would derive as follows:
s = 3d // Son's share is 3 x daughter's
d = 2m // Mom's share is 2 x mother's
As + Bd + m = 1920000
A(6m) + B(2m) + m = 1920000
m = 1920000 / (6A + 2B + 1)
Here is a Java program to show all possible combinations between 0 and 9 sons and/or daughters (assuming only one mother!):

 Consider Paul's rocket mass heater.