Henry Posted November 21, 2003 Posted November 21, 2003 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
Lee Smith Posted November 21, 2003 Posted November 21, 2003 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
zincb Posted November 21, 2003 Posted November 21, 2003 UPDATED ATTACHMENT Here is one solution that uses the Sieve of Eratosthenes to find a solution. PrimeDirective.zip
Henry Posted November 21, 2003 Author Posted November 21, 2003 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 "
Henry Posted November 21, 2003 Author Posted November 21, 2003 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
zincb Posted November 21, 2003 Posted November 21, 2003 Here is a solution that provides the output that you wanted: PrimeDirective.zip
BobWeaver Posted November 22, 2003 Posted November 22, 2003 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
Recommended Posts
This topic is 8033 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now