Pairs that have common divisors | Matlab Examples

Matlab Tutorials | Examples

Practice 4:

Pairs that have common divisors

Write a MATLAB program that does the following jobs:

  1. Get two whole numbers (a and b) greater than 1. If any of the numbers do not satisfy the criteria, display a warning message and stop the program.
  2. For all pairs of numbers between [a…b] (both inclusive) find all positive common divisors greater than 1 and display them as in the sample output below.

 

 

Solution:

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *