Determine if x is a combination of m and n - MATLAB Cody - MATLAB Central

Problem 55235. Determine if x is a combination of m and n

Difficulty:Rate
Given positive integers x, m, and n, determine if x can be written as x = am + bn for any (non-negative) integers a and b. Your function should return logical true or false.
For example
  • iscombo(17,3,5) should return true because 17 = 4*3 + 1*5
  • iscombo(18,3,5) should return true because 18 = 6*3 + 0*5
  • iscombo(7,3,5) should return false because 7 cannot be written as a combination of 3 & 5 (7 is not divisible by either 3 or 5 and 1*3 + 1*5 = 8)
Hint: You can start by calculating all possible values of combining m and n

Solution Stats

38.01% Correct | 61.99% Incorrect
Last Solution submitted on Mar 03, 2025

Problem Comments

Solution Comments

Show comments
Primes and Rough Numbers, Basic ideas
What is a rough number? What can they be used...
3
4

Problem Recent Solvers330

Suggested Problems

More from this Author10

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page