MAT

Riddle #1

Finds the sum of all multiples of a number N less than M (excluding).

Constraints

1 < N < 103
N < M < 108

Example

Multiples of N = 10 less than M = 100 are:

10, 20, 30, 40, 50, 60, 70, 80, 90

Therefore their sum is: 450

Your program

<?php
    
function main ($N, $M) {

  $return = 0;
  /* Write your function here */
  
  return $return;
}
  
$IN = (array) json_decode(base64_decode($argv[1]));
extract($IN);
echo main($N, $M);
?>

Your input

{ 
  "N": 10, 
  "M": 100 
}

Your output

-

Correct output

450

0 0 votes
Article Rating
Notifiche
Notificami
0 Comments
Inline Feedbacks
View all comments