/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] while problem

Hi guys,

I have a while loop in here that makes me think, what’s wrong? If I execute it the browser seems to take a lot of time to execute it, I did set the set_time_limit to 0, still it won’t execute. Here’s the code:

[code=php]
<?php
set_time_limit(0);

$a = 0;
$b = 1;
$c = 0;
$i = 0;
$j = 1;
$even_count = 0;

while($i < 10) {
$c = $a + $b;
$a = $b;
$b = $c;
if($c % 2 == 0) {
$even_count += $c;
}
}

echo “Sum of all even-valued terms: ” . $even_count;
?>
[/code]

Any help is deeply appreciated. ?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@kingdmauthorOct 24.2010 — Sorry, my bad. I've seen the error I forgot to place an increment for $i. ?
×

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 5.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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