/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] bcmath problem

Hi,

I try to run this code, but whenever I am to, the browser would result to not responding, what seems to be the error?

[code=php]
<?php
$a = 0;
$b = 1;
$c = 0;
$i = 0;
$even_count = 0;
while($i < 5) {
$c = bcadd($a, $b);
$a = $b;
$b = $c;
if (bcmod($c, 2) == 0) {
$even_count = bcadd($even_count, $c);
}
$i++;
}
echo “Sum of all even-valued terms: ” . $even_count;

?>
[/code]

Any inputs is appreciated. ?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 24.2010 — Runs OK for me, outputting: "Sum of all even-valued terms: 10".
Copy linkTweet thisAlerts:
@kingdmauthorOct 25.2010 — Thanks NogDog,

It's really weird after a few restarts of my server, that's when everythings' went fine. Well anyway, thanks a lot boss ?
×

Success!

Help @kingdm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...