Jump to content

Lowest Common Denominator


This topic is 6350 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi Forum - I am using Filemaker 7 client and need the following calc :)- The Lowest Common Denominator (actually what I think I need is greatest common factor) over 5 columns. Not sure if I would actally need more than one field because it would run something like this - LCD(field1, field2, field3, field4, field5)

Any suggestions ?

Many thanks in advance

Glorifindal

Edited by Guest
Link to comment
Share on other sites

Welcome to the Forums.

Nothing like starting with an easy one?

The way to calculate this is by finding the prime factors for each of the five fields.

Field1 = 21 = 3 x 7

Field2 = 42 = 2 x 3 x 7

Field3 = 49 = 7 x 7

Field4 = 63 = 3 x 3 x 7

Field5 = 77 = 7 x 11

Now multiple the factor pairing combinations to receive the lowest common denominator.

2 x 3 x 3 x 7 x 7 x 11 = 9702

The factor pairing break down:

Field1 = 3 (3rd factor) x 7 (4th factor)

Field2 = 2 (1st factor) x 3 (2nd factor) and 3 (3rd factor) x 7 (4th factor) and 2 (1st factor) x 7 (4th factor)

Field3 = 7 (4th factor) x 7 (5th factor)

Field4 = 3 (2nd factor) x 3 (3rd factor) and 3 (3rd factor) x 7 (4th factor) and 3 (3rd factor) x 7 (4th factor)

Field5 = 7 (5th factor) x 11 (6th factor)

LCD = 9702

This could be completed in one complex, recursive, custom function or by combining a simpler, recursive, custom function used in five fields and a second recursive, custom function to put the prime factors together.

Link to comment
Share on other sites

OK, so many thanks for the suggestions - I have to admit I am lost on both - I really need to work over 5 fields - all 5 fields will add up to 100 percent - so it could be field1 = 5, field2 = 5, field3 = 20, field4 = 30, field5 = 40.

To explain - I started off with 2 fields, 80% and 20% - the result being 4 which is 80 divided by 20 without a reminder - and it has now become 5 fields.

I am unable to grasp how to implement the first suggestion OR modify the second suggestion - lost in space really

Anyone able to help ?

Glorifindal

Link to comment
Share on other sites

Thanks for the quick reply

I need what I think is the lowest common multiple i.e for my first example it was field1 = 80, field2 = 20, calc = 4 - which was the highest divided by the lowest - in this example there was nothing left over so 4 is correct - divide 84 by 18 to get a quotient of 4 and a remainder of 12. Then divide 18 by 12 to get a quotient of 1 and a remainder of 6. Then divide 12 by 6 to get a remainder of 0, which means that 6 is the gcd - which is only possible with 2 integers - I need to do this with 5 integers.

Is my need any clearer ?

Many thanks

Glorifindal

Link to comment
Share on other sites

No, I am afraid it's even more confusing. Perhaps if you explained what these number represent, and what do you REALLY need to know as a result of the calculation. Surely, unless this is an excercise in math, you are not really interested in the GCD as such?

In general, to get the GCD of more than two numbers, I think you would start with any two, then repeat the process with the first result and the third number as input, and so on. But I have a feeling this might not be required.

Link to comment
Share on other sites

Glorifindal,

From the earlier example:

field1 = 5, field2 = 5, field3 = 20, field4 = 30, field5 = 40

Lowest Commmon Multiple = 120

Greatest Common Demonimator = 5

If I understand your example correctly then these should be your answers?

In the later explanation, I do not understand where the "divide 84 by 18 to get a quotient of 4..." numbers come from. 84 = field1 (80) + GCD of field1 and field2?

Do a search on the interweb for Lowest Commmon Multiple and Greatest Common Demonimator to see what they are and how they are calculated.

Link to comment
Share on other sites

This link to the custom function above appears to be the start of what you're looking for..the Greatest Common Factor. But this function only covers 2 values.

To get our 5 values, install the function GCF from Scott Morrison referenced above. Then create a new one

GCF5 = GCF(E;GCF(D;GCF(D;GCF(C;GCF(B ; Mod(A ;B) ) ))))

with parameters A, B, C, D, E

There might be a more elegant solution (I'm just starting at CF development) but it works.

G

Link to comment
Share on other sites

Firstly, MANY thanks indeed for the help - OK, I will attempt to explain the issue properly - I have 5 sets of data - differant levels as it were. Each set has a differant "weight" i.e a differant percent. In order to work out the average over the differant weights, I have to bring it to the greatest common multiple.

So, my example of 80 and 20 gives me 4 - as said, this example only works easily because there is no remainder, and because I concentrated on only 2 integers - but I need this to work out for 5 integers -

Is that any clearer ? Excuse me please if not

kind regards

Glorifindal

Link to comment
Share on other sites

I am afraid it still doesn't make much sense to me. I think I understand weighted average. I have no idea what GCD has to do with it, or why should one care about remainders.

Let's take a simple example with 3 sets of data:

Level1 = 50;

Level2 = 30;

Level3 = 20;

Weight1 = 20;

Weight2 = 50;

Weight3 = 130;

Now you can calculate:

SumWeight = 200;

Product1 = Level1 * Weight1 = 50 * 20 = 1000;

Product2 = Level2 * Weight2 = 30 * 50 = 1500;

Product3 = Level3 * Weight3 = 20 * 130 = 2600;

SumProduct = 5100;

WeightedAverage = SumProduct / SumWeight = 5100 / 200 = 25.5

If this is not what you want, then please give me a similar example of what you do need.

Link to comment
Share on other sites

Now it's unclear.

The GCD of 80 and 20 is 20. 20 will divide into 80 and 20 both without a remainder. The average value of 5 values that always add up to 100 will always be 20.

Tell us the actual problem you're trying to solve instead of stripping away information and we might be able help.

>>>I re read the thread and realize that comment's post is probably the answer you're looking for. Much easier to help when we see the problem, rather than what your idea of the problem is.

Edited by Guest
Reread other followup
Link to comment
Share on other sites

This topic is 6350 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.