Overview
This VI shows how to solve Project Euler Problem #5.
Description
Project Euler Problem #5:
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
More information about Project Euler can be found @ www.projecteuler.net
Note: This code implements a brute force method. May take several seconds to complete when "Numeric Control" > 15
Requirements
Steps to Implement or Execute Code
Additional Information or References


**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
You do like the brute force, don't you. Part of the point of Project Euler is elegant and efficient solutions. Let's break this problem down a bit. What does it mean that a number X is divisible by all the number 1..N?
First, X will be divisible by all of the primes in 1..N. For instance, 2520 is divisible by 2, 3, 5, and 7, the primes in 1..10.
Second, X will need to be multiply divisible by these primes, up to a certain factor. By this I mean that, for example, 2520 must be divisible by 8, which is 2*2*2.The certain factor is (in this example) 10.
So, we can construct a more elegant and efficient solution:
1. Start with a value of 1.
2. Loop over the numbers 2..N.
3. If our current iteration is a prime, multiply the prime by itself until it is just under N. Multiply our result by this value.
4. Skip non-primes.
I'll post my solution shortly (after I figure out how.....)
Ok, I can't figure out how to upload my VI.