create account

RE: Introducing the Coding Challenge by gokulnk

View this thread on: hive.blogpeakd.comecency.com

Viewing a response to: @reggaemuffin/introducing-the-coding-challenge

· @gokulnk ·
$0.37
```php
<?php
function fizzbuzz ($n) {
    $message = "";
    if ($n%3 == 0 || $n%5 == 0) {
        if ($n%3 == 0) {
            $message .= "Fizz";
        }
        if ($n%5 == 0) {
            $message .= "Buzz";
        }
    }
    else {
        $message .= (string)($n);
    }
    echo $message;
}
function test() {
    for ($i=-10; $i<11 ; $i++) {
        echo $i .  ") ";
        echo fizzbuzz($i);
        echo  "\n";
    }
}
test();
?>
```

Using bracket condition for divisibility for 3 & 5. Starting with 3 as more numbers will be divisible by 3. 

Output

```
-10) Buzz
-9) Fizz
-8) -8
-7) -7
-6) Fizz
-5) Buzz
-4) -4
-3) Fizz
-2) -2
-1) -1
0) FizzBuzz
1) 1
2) 2
3) Fizz
4) 4
5) Buzz
6) Fizz
7) 7
8) 8
9) Fizz
10) Buzz
```

<br/>
Do checkout my [programming challenge](https://steemit.com/steemgig/@gokulnk/programming-challenge-1-break-it-down-further) as well.
👍  
properties (23)
authorgokulnk
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t183339395z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"links":["https://steemit.com/steemgig/@gokulnk/programming-challenge-1-break-it-down-further"],"app":"steemit/0.1"}
created2017-08-17 18:33:39
last_update2017-08-17 18:33:39
depth1
children1
last_payout2017-08-24 18:33:39
cashout_time1969-12-31 23:59:59
total_payout_value0.274 HBD
curator_payout_value0.091 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length874
author_reputation17,871,219,215,380
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,109,684
net_rshares105,637,451,265
author_curate_reward""
vote details (1)
@reggaemuffin ·
I submitted an entry for your challenge, pretty cool :)
properties (22)
authorreggaemuffin
permlinkre-gokulnk-re-reggaemuffin-introducing-the-coding-challenge-20170817t192928190z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 19:29:30
last_update2017-08-17 19:29:30
depth2
children0
last_payout2017-08-24 19:29:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length55
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,113,631
net_rshares0