Skip to content

From Small to BIGGER

Menu
  • Home
  • About Us
  • Portofolio
  • Contact
Menu

Hackerrank – FizzBuzz

Posted on June 1, 2022January 16, 2023 by kura
<?php
function fizzBuzz($n) {
    // Write your code here
    for ($i=1; $i<=$n; $i++) {
        if ($i % 3 == 0 && $i % 5 == 0) {
            echo "FizzBuzz\n";
        } elseif ($i % 3 == 0) {
            echo "Fizz\n";
        } elseif ($i % 5 == 0) {
            echo "Buzz\n";
        } else {
            echo $i."\n";
        }
    }
}

$n = intval(trim(fgets(STDIN)));
FacebookTweetLinkedIn

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Laravel & Datatables – Server Side Manualy
  • Linux – User Login Set Directory & Set Permission
  • Javascript Call Function From iFrame
  • Python – Create data dummy attendance
  • PHPWord Convert HTML + PDF

Categories

  • Apache
  • Database
  • Freeradius
  • Javascript
  • Mikrotik
  • Mysql
  • Networking
  • PHP
  • Postgresql
  • Programming
  • Python
  • Server
©2025 From Small to BIGGER | Built using WordPress and Responsive Blogily theme by Superb