codingtests/solutions/other/multipleof3and5.php

10 lines
258 B
PHP
Raw Permalink Normal View History

2024-07-23 09:13:29 +00:00
<?php
//Write a program or solve manually to find the smallest positive number that is evenly divisible by all of the numbers from 1 to 20.
$m3 = range(3, 1000, 3);
$m5 = range(5, 1000, 5);
$all = array_unique(array_merge($m3,$m5));
echo array_sum($all);