Viewing a response to: @reggaemuffin/introducing-the-coding-challenge
```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.
author | gokulnk |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t183339395z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"links":["https://steemit.com/steemgig/@gokulnk/programming-challenge-1-break-it-down-further"],"app":"steemit/0.1"} |
created | 2017-08-17 18:33:39 |
last_update | 2017-08-17 18:33:39 |
depth | 1 |
children | 1 |
last_payout | 2017-08-24 18:33:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.274 HBD |
curator_payout_value | 0.091 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 874 |
author_reputation | 17,871,219,215,380 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,109,684 |
net_rshares | 105,637,451,265 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 105,637,451,265 | 1% |
I submitted an entry for your challenge, pretty cool :)
author | reggaemuffin |
---|---|
permlink | re-gokulnk-re-reggaemuffin-introducing-the-coding-challenge-20170817t192928190z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 19:29:30 |
last_update | 2017-08-17 19:29:30 |
depth | 2 |
children | 0 |
last_payout | 2017-08-24 19:29:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 55 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,113,631 |
net_rshares | 0 |