Nuts, girl and boys

Milena collected fallen nuts and called a bunch of boys let them share. She took a condition: the first boy takes one nut and tenth of the rest, the second takes 2 nuts and tenth new rest, the third takes 3 nuts and tenth new rest and so on. Thus managed to distribute all the nuts and everyone got same amounth.

Determine how many nuts gathered Milena and many boys divided the nuts.

Result

nuts:  81
boys:  9

Solution:

Program in PHP:
for($o=2;$o<1000; $o++)
{
    $oo = $o;
    $ch = 1;

    $stack = array();
    do
    {
        $d = $ch + ($oo-$ch)/10;
        if($d != (int)$d)
        {
           continue(2);
        }
        $oo -= $d;
        $ch++;
        $stack[] = $d;
    }while($oo>0);

    if($oo==0)
    {
        echo "nuts=$o boys=$ch";
        print_r($stack);
        exit;
    }
}








Leave us a comment of example and its solution (i.e. if it is still somewhat unclear...):

Showing 0 comments:
1st comment
Be the first to comment!
avatar




Next similar examples:

  1. Girls
    skola_10 The boys and girls in the class formed without the rest of the fives, 2 girls and 3 boys. There are 6 girls missing to create mixed pairs (1 boy and 1 girl). How many girls are in the classroom?
  2. Clothes
    dvojice_2 Danka and Janka collect clothes. Danka had 9 more than Janka, so she gave her 7. Which now has more cloth and how many?
  3. Snacks
    skola_9 The school attends 344 pupils. Half of them take snacks. 13 pupils who took snacks did not attend school. How many snacks left?
  4. Repair pipe
    workers_39 20 workers had to repair broken pipes in 30 days. After fourteen days, four laborers joined them. How long did the pipe repair work last?
  5. Three students
    terc2_2 Three students independently try to solve the problem. The first student will solve a similar problem with a probability of 0.6, the second student will solve at a probability of 0.55, and the third will solve at a probability 0.04. The problem is resolved
  6. Four numbers
    equilateral_triangle_5 The first number is 50% second, the second number is 40% third, the third number is 20% of the fourth. The sum is 396. What are the numbers?
  7. Garden
    garden_1 Area of square garden is 4/5 of triangle garden with sides 24 m, 15 m and 15 m. How many meters of fencing need to fence a square garden?
  8. Rectangles
    rectangle_15 The perimeter of a rectangle is 90 m. Divide it into three rectangles, the shorter side has all three rectangles the same, their longer sides are three consecutive natural numbers. What is the dimensions of each rectangle?
  9. Candy and boxes
    cukriky_13 We have some number of candy and empty boxes. When we put candies in boxes of ten, there will be 2 candies and 8 empty boxes left, when of eight, there will be 6 candies and 3 boxes left. How many candy and empty boxes left when we put candies in boxes of.
  10. Three friends
    gulky_9 Three friends had balls in ratio 2: 7: 4 at the start of the game. Could they have the same number of balls at the end of the game? Write 0, if not, or write the minimum number of balls they had together.
  11. School
    ziaci_6 Less than 500 pupils attend school. When it is sorted into pairs, one pupil remains. Similarly, when sorted into 3, 4, 5 and 6 members team one remains. Sorted to seven members teams, no left behind. How many pupils are attending this school?
  12. TV fail
    old_tv The TV has after 10,000 hours average 25 failures. Determine the probability of TV failure after 200 hours of operation.
  13. Bridge cards
    cards2 How many bridge hands are possible containing 4 spades,6 diamonds, 1 club, and 2 hearts?
  14. Carpet
    koberec_2 The room is 10 x 5 meters. You have the role of carpet width of 1 meter. Make rectangular cut of roll that piece of carpet will be longest possible and it fit into the room. How long is a piece of carpet? Note .: carpet will not be parallel with the diag
  15. Brick
    brick One brick is 6 kg and half a brick heavy. What is the weight of one brick?
  16. Right triangle eq2
    rt_triangle_1 Find the lengths of the sides and the angles in the right triangle. Given area S = 210 and perimeter o = 70.
  17. Book reading
    books_30 If we read the book at a speed of 15 pages a day, we read it 3 days before we read it at a speed of 10 pages per day. If I read at 6 pages per day, how many days will I read the book?