November 21, 200322 yr Hi there, just want to know how to capture all the prime number between a range and then store the result into a field. Regards, Henry
November 21, 200322 yr Hi Henry, How about a few examples of the text/field data that contains "prime number between a range" so we can see the patterns involved. Lee
November 21, 200322 yr UPDATED ATTACHMENT Here is one solution that uses the Sieve of Eratosthenes to find a solution. PrimeDirective.zip
November 21, 200322 yr Author The example is for the number range 10 to 20 ( the range can define by user), the result will be 11, 13, 17, 19 The end result can store in a text field and seperate each number by a return "
November 21, 200322 yr Author Addition information The range is define with 2 number field, it is define by user, user can key in the range themself. After they key in the two number, they can click a button to capture/calculate out all the prime number between the range. another example: range 20 to 35 the result will be : 23, 29, 31 Regards, Henry
November 21, 200322 yr Here is a solution that provides the output that you wanted: PrimeDirective.zip
November 22, 200322 yr While the Sieve of Eratosthenes method can be efficient in certain situations such as a very large range, or a small range that starts at a very high number, it is hard to implement a fast version in Filemaker because of the speed of record creation. I think in this case, the old brute force method is actually quicker. See attachment. FindPrimes.fp5.zip
Create an account or sign in to comment