Forum Discussion
Lowest Common Multiple
- Mar 15, 2024
SergeiBaklan Well I took on the challenge and got somewhere with it. (attached). To do this I created a few Lambda functions:
PrimeFactors256 => returns an array with # of times each of the first 256 prime #s are a factor in the value and the 257th value is either a 1 indicating all the factors were found or the value of the 1 remaining prime factor. Since the 256th prime# is 1619 this will effectively find the Prime Factors for any number up to 1619^2.
PrimeFactors => uses PrimeFactors256 but then appends the actual prime numbers and filters the list to only those non-zero and essentially just a nicer/readable output for PrimeFactors256
LCM_prime => uses Prime Number technique to find the LCM. So this will use PrimeFactors256 and loop through all values inthe array keeping the max repeats of each of the 1st 256 primes and then tack on a unique list of primes above the 256th (those will always be a max of 1 for the valid range) and at the end basically multiple them all together.This function worked on sheet1 and will "work" on the sheet 2 BUT clearly is outputting a value that is affected by excel's limited number of significant digits. So assuming it has a good list of primes we could go down that road of 'big number calculation' again. I'm just happy to get the function to work in what i believe is a pretty efficient manner.
Here Determining The Least Common Multiple In Excel - ExcelAdept are variants for LCM calculation. Perhaps #3 could work with big integers. Will try with formula when have more time, that's not 5 minutes job. At least for me.
- ESAM_HASHIMMar 12, 2024Brass Contributor
Thank you SergeiBaklan for your responding
I would like to inform you that the link did not open, unfortunately- SergeiBaklanMar 13, 2024Diamond Contributor
Sorry, I have no idea why you are not able to open the link. In my case it works if I click on it in above post.
- ESAM_HASHIMMar 13, 2024Brass Contributor