22 lines
455 B
PHP
22 lines
455 B
PHP
<?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;
|
|
}}}}}}}}}
|
|
}
|
|
}
|