MAT

Riddle #2

Find the sum of all multiples of two numbers A and B less than M (excluding).

Constraints

1 < A < B < 103
B < M < 108

Example

Multiples of A = 3 and B = 5 less than M = 20 are:

3, 5, 6, 9, 10, 12, 15, 18

Therefore their sum is: 78

Your program

<?php
    
function main($A, $B, $M) {

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

Your input

{ 
  "A": 3,
  "B": 5,
  "M": 20 
}

Your output

-

Correct output

78

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