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. Z9-I-4
    numbers_30 Kate thought a five-digit integer. She wrote the sum of this number and its half at the first line to the workbook. On the second line wrote a total of this number and its one fifth. On the third row she wrote a sum of this number and its one nines. Fi
  2. Camel
    camels Camel owner wants to get out of the city into oasis. He bought 3000 bananas, which wants to sell in oasis. However oasis from the city divided 1,000 kilometers of desert. Camel can carry at one time up to 1000 bananas, and for every kilometer traveled, ea
  3. Octahedron - sum
    8sten On each wall of a regular octahedron is written one of the numbers 1, 2, 3, 4, 5, 6, 7 and 8, wherein on different sides are different numbers. For each wall John make the sum of the numbers written of three adjacent walls. Thus got eight sums, which also.
  4. Euler problem
    euler Someone buys a 180 tolars towels. If it was for the same money of 3 more towels, it would be 3 tolars cheaper each. How many were towels?
  5. Numbers
    ten Determine the number of all positive integers less than 4183444 if each is divisible by 29, 7, 17. What is its sum?
  6. Divisibility
    dots Determine the smallest integer which divided 11 gives remainder 4 when divided 15 gives remainder 10 and when divided by 19 gives remainder 16.
  7. Digits
    seq_5 Show that if x, y, z are 3 consecutive nonzero digits, zyx-xyz = 198, where zyx and xyz are three-digit numbers created from x, y, z.
  8. No. of divisors
    triangle_div How many different divisors has number ??
  9. Diofant equation
    diofantos In the set of integers (Z) solve the equation: ? Write result with integer parameter ? (parameter t = ...-2,-1,0,1,2,3... if equation has infinitely many solutions)
  10. Last digit
    olympics_3 What is the last number of 2016 power of 2017
  11. Z9–I–1
    ctverec_mo In all nine fields of given shape to be filled natural numbers so that: • each of the numbers 2, 4, 6 and 8 is used at least once, • four of the inner square boxes containing the products of the numbers of adjacent cells of the outer square, • in the cir
  12. Diofant 2
    1diofantos Is equation ? solvable on the set of integers Z?
  13. Monkey
    monkey Monkey fell in 38 m deep well. Every day her scramble 3 meters, at night dropped back by 2 m. On that day it gets hangover from the well?
  14. Shelf
    bookshelf.JPG How many ways are there to arrange 6 books on a shelf?
  15. Seedcake
    pletenky Seedcake costs 44 cents. How many minimum seedcakes we must buy that we can pay in cash only whole euros?
  16. Rectangles
    rectangles How many rectangles with area 3002 cm2 whose sides is natural numbers are?
  17. Steps
    square_diagonal_1 How many steps you save if you go square estate for diagonal (crosswise), rather than circumvent on the two sides of its perimeter with 307 steps.