A problem
Lesson 14 of 20 in Coddy's Mathematical Riddles course.
The least common multiplier can be applied to more than two numbers.
It obeys the following:
LCM(x,y,z) = LCM(LCM(x,y),z)
Challenge
EasyWrite a function calcSmallestNumberDivideableBy1toN that gets an integer, N, and calculates the smallest number that can be divided by each of the numbers from 1 to N without any remainder.
Try it yourself
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "solution.h"
int main() {
int n;
if (scanf("%d", &n) != 1) n = 0;
int r = calcSmallestNumberDivideableBy1toN(n);
printf("%d\n", r);
return 0;
}