php-windows Digest 21 Apr 2005 02:43:11 -0000 Issue 2640

Topics (messages 25883 through 25890):

Re: Jaw Breaker - What's the ansewer?
        25883 by: M. Sokolewicz
        25884 by: JC Botha
        25885 by: graeme
        25886 by: graeme
        25887 by: JC Botha
        25890 by: Wu, Jin Yong

PHP cannot load extensions
        25888 by: chistian

nuSoap and PHP 4.3.11
        25889 by: Charles P. Killmer

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message --- 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.
]]

--- End Message ---
--- Begin Message ---
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
> 
>

--- End Message ---
--- Begin Message --- 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
--- End Message ---
--- Begin Message ---
Yes it is an issue with floating point numbers since:

8.35 will give the answer but if you increment by .01 in a loop then you will not get the answer, when it is on 8.35. However, increment by 0.001 then 8.35 will provide the correct answer. It's all to do with how in calculates 0.01 in binary, a rational fraction in binary.

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
--- End Message ---
--- Begin Message ---
Well done Graeme!

Posted below is what I used to generate the asnwer, I myself had
dificulty to get it. Let me know if you used another method.

The Source Code
==================================================
<?php
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);
  }
      $x = 0.00;
   while ($x < 10){

      $x = round($x, 2) + 0.01;
      $l = (g($x));

      if ($l == 4277108){
              echo("<font color='red'>:: x = $x : $l</font> <br/>");
       }
      //echo ("> $x : $l<br/>");

   }

?>

=================================================

On 4/20/05, graeme <[EMAIL PROTECTED]> wrote:
> Yes it is an issue with floating point numbers since:
> 
> 8.35 will give the answer but if you increment by .01 in a loop then you
> will not get the answer, when it is on 8.35. However, increment by 0.001
> then 8.35 will provide the correct answer. It's all to do with how in
> calculates 0.01 in binary, a rational fraction in binary.
> 
> 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
> 
>

--- End Message ---
--- Begin Message ---
It's so interesting. At the beginning, I missed the statement "$x =
round($x, 2) + 0.01;",
and can't get corrent answer.Then, I trace the $x value, I found its value
was changed to have
13 decimal places from 4.43 on. Could you explain it for me?thank you ahead.

-----Original Message-----
From: JC Botha [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 20, 2005 19:50 PM
To: graeme
Cc: [email protected]
Subject: Re: [PHP-WIN] Re: Jaw Breaker - What's the ansewer?


Well done Graeme!

Posted below is what I used to generate the asnwer, I myself had
dificulty to get it. Let me know if you used another method.

The Source Code
==================================================
<?php
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);
  }
      $x = 0.00;
   while ($x < 10){

      $x = round($x, 2) + 0.01;
      $l = (g($x));

      if ($l == 4277108){
              echo("<font color='red'>:: x = $x : $l</font> <br/>");
       }
      //echo ("> $x : $l<br/>");

   }

?>

=================================================

On 4/20/05, graeme <[EMAIL PROTECTED]> wrote:
> Yes it is an issue with floating point numbers since:
> 
> 8.35 will give the answer but if you increment by .01 in a loop then you
> will not get the answer, when it is on 8.35. However, increment by 0.001
> then 8.35 will provide the correct answer. It's all to do with how in
> calculates 0.01 in binary, a rational fraction in binary.
> 
> 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

--- End Message ---
--- Begin Message ---
Hi,

I've installed PhpMyAdmin 2.6.2, PHP 5.0.4 and Mysql 4.1.11 and PHP is 
working fine but when I try to start PhpAdmin I get this message:
"PHP cannot load mysqli extensions, please controll your PHP configuration".
In "Paths and directories" I wrote:
extensions_dir="e:\php\ext\"
and in "Dynamics extensions" I wrote:
extensions=php_mysqi.dll.
All that on a w2k server with IIS 5 and mysql is running as a service.
Can someone give me little help on that ?
Thanks in advance.
Chris 

--- End Message ---
--- Begin Message ---
I just upgraded to 4.3.11 and now my web service apps do not work.  I
downloaded the latest version of nuSoap.php and still no luck.  Is
anyone else running into issues with this?
 
 
Charles Killmer
 

--- End Message ---

Reply via email to