codingtests/solutions/other/sumdiv20.php

22 lines
455 B
PHP
Raw Normal View History

2024-07-23 09:13:29 +00:00
<?php
//Write a function to find the smallest number that is divisible by each of the numbers from 1 to 20.
function sumdiv20() {
$i = 20;
while(true) {
$i += 20;
if($i %19== 0) {
if($i %18== 0) {
if($i %17== 0) {
if($i %16== 0) {
if($i %15== 0) {
if($i %14== 0) {
if($i %13== 0) {
if($i %12== 0) {
if($i %11== 0) {
return $i;
}}}}}}}}}
}
}