Q:

Write a PHP program to test if a given non-negative number is a multiple of 13 or it is one more than a multiple of 13

0

Write a PHP program to test if a given non-negative number is a multiple of 13 or it is one more than a multiple of 13.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
function test($n)
{
   return $n % 13 == 0 || $n % 13 == 1;
 }

var_dump(test(13));
var_dump(test(14));
var_dump(test(27));
var_dump(test(41));

Sample Output:

bool(true)
bool(true)
bool(true)
bool(false)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now