Jump to content
Updating IPB tonight Read more... ×

Archived

This topic is now archived and is closed to further replies.

Rehehelly

My minds gone blank - Calculating

Recommended Posts

Okay, so.. i'm tired, probably not the best time to be doing this, but.. maeh.

Say I have a list of seconds to get to a game level,

Level 1. 1000
Level 2. 2000
Level 3. 3000
Level 4. 4000
and so on, if I wanted to calculate how many seconds to get from level 1 to level 50. How would I go about doing that?

I told you my mind has gone blank >.<

Thanks
~Dan

Share this post


Link to post
Share on other sites
I really should have clarified that. I mean like

Add level 1, level 2, level 3, level 4, level 5, level 6, level 7 etc. till you get to level 50.

Share this post


Link to post
Share on other sites
Then it'll be a woping total of 1,275,000 secounds!!

This how I worked it out:
[code]<?php
$s = "\$sec = ";
for($i = 1; $i < 50; $i++)
{
    $s .= ($i*1000).'+';
}

$s .= "50000;";

echo eval($s);
echo $sec;

?>[/code]

Share this post


Link to post
Share on other sites
Wildteen,

Seems a roundabout way of doing it !

[code]$sec = 0;
for ($i=1; $i <= 50; $i++) {
     $sec += $i * 1000;
}
echo $sec;[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.