Similar Posts

Subscribe
Notify of
6 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
aperfect10
11 months ago

Part b) requires a function which calculates the largest common divider (ggT) for two numbers, a and b. So a picture showing two numbers to another number:

Now we need an accurate mapping rule. To this end, we recall the mathematical definition of ggT:

For two natural numbers a and b, the ggT d is the largest number, so that d divides a and d splits b.

The amount of all the numbers that share a and b can be written down formally:

Now you have to mark that you have largest Element of this amount. To do this, you can use a specific function… After that you have your searched mapping rule.

For c): In order for the algorithm to be correct, Alg(a,b) must correspond to ggT(a,b) for all natural a and b. So the sentence is:

WitchHunter0815
11 months ago

Here, as an example, the partial quantity method:

int Teilermengen_ggT(int a, int b)
{
    int retval = 1;
    for (int i = 2; i <= a && i <= b; i++)
    {
        if (a % i == 0 && b % i == 0)
        {
            retval = i;
        }
    }
    return retval;
}
WitchHunter0815
11 months ago
Reply to  Francisco1234

Well, the subset process is quite simple and simple:
Parts each of the two numbers by all numbers with 1 starting incl. self without remainder. Now find the largest number in both quantities.

Tannibi
11 months ago

At b you best take the Euclidean algorithm,
this saves the prime factor decomposition.

At c, I don’t know how it is meant.
A correct solution would be “The algorithm Alg(a, b)
calculates the ggT of a and b”, but this is probably not meant.