Help with these algorithms .... !!!!?

1.- Given two numbers count how many divisors has the first are smaller than the second

2.- Given 2 numbers count how many dividers each has

2 Answers

  • 4 years ago

    1. Just loop from k=1 to (second number)-1 and count how many values of k divide (first number) evenly.

    2. Is this supposed to be common divisors? i.e. counting how many different numbers will evenly divide both input numbers? If so, just loop from k=1 to min(first, second) and count 1 each time k divides both first and second.

    If you really mean problem 2 to be as stated, then simply write a divisor count procedure for a single number, then perform that procedure for each of the two input values.

Still have questions? Get answers by asking now.