02-09-2019 21:41 PM
02-09-2019 09:41 PM
This nifty little Quick Measure will tell you if a number is prime or not.
mIsPrime = VAR __num = MAX([Number]) VAR __max = INT(SQRT(__num)) VAR __table = GENERATESERIES(2,__max,1) VAR __table1 = ADDCOLUMNS(__table,"__mod",MOD(__num,[Value])) RETURN SWITCH(TRUE(), __num = 1, 0, ISBLANK(COUNTROWS(FILTER(__table1,[__mod]=0))),1, 0 )
Basically, compute the nearest integer to the square root of the number. Generate a table of all values between 2 and that number. Compute the modulus of the number in question and each of the table values. If one of the rows has a modulus of 0, it's not a prime number.
Included in the file is a representation of the Ulam Spiral, a nifty little construct that occurs when you write positive integers down in a square spiral pattern like:
Apparently, Ulam discovered the spiral in 1963 while doodling during the presentation of "a long and very boring paper" at a scientific meeting. This narrows down the potential presentations by exactly 0.
Did I answer your question? Mark my post as a solution!
Proud to be a Datanaut!