Well the closest I got was $x = 8.36 but that only gave 4277126.8 So is this question dependent upon the floating point arithmetic that is used?

graeme

JC Botha wrote:

It is possible, and "10.642868165785" is incorrect. The question says
"$x is a number between 1 and 10 and has 2 decimal places."

Try again, if more try then I will post the source code that generates
the asnwer?



On 4/20/05, M. Sokolewicz <[EMAIL PROTECTED]> wrote:


JC Botha wrote:


The following is a section of PHP code (see Apache.org and PHP.net).

 function f($c) {
   $c++;
   if ($c % 2) { return f($c); }
   return $c++;
 }

 function g($n) {
   for ($i=1;$i<10;$i++) {
     $n = f($n*$i);
   }
   return ($n);
 }

 print(g($x));

What is the smallest value that $x can have if 4277108 is outputted to
the screen after running this code?
$x is a number between 1 and 10 and has 2 decimal places.


it's not a jawbreaker, it's impossible IMO.
f() always returns the number if it's uneven, or if it's even, it
returns (n+1). So, it always returns uneven. which means the result of
g() can *never* be even.

[[side note:
unless "return $c++;" does first add 1 to it before returning, but I
think it doesn't, since it's a postincrement operator.
]]

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php








-- Experience is a good teacher, but she sends in terrific bills.

Minna Antrim

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to