{"id":20750,"date":"2021-09-30T11:30:20","date_gmt":"2021-09-30T06:00:20","guid":{"rendered":"https:\/\/python-programs.com\/?p=20750"},"modified":"2021-11-22T18:35:29","modified_gmt":"2021-11-22T13:05:29","slug":"python-program-for-given-two-numbers-a-and-b-find-all-x-such-that-a-x-b","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-given-two-numbers-a-and-b-find-all-x-such-that-a-x-b\/","title":{"rendered":"Python Program for Given Two Numbers a and b Find all x Such that a % x = b"},"content":{"rendered":"

In the previous article, we have discussed Python Program for Modular Multiplicative Inverse from 1 to n<\/a><\/p>\n

Given two numbers a, b and the task is to find all x such that given a % x = b<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given a value = 21\r\nGiven b value = 5<\/pre>\n

Output:<\/strong><\/p>\n

The value of x such that given a%x==b {a,b = 21 5 } =  2<\/pre>\n

Explanation:<\/strong><\/p>\n

Here the values of x which satisfy a%x=b are 8,16 because 21%8=5 ,21%16=5.\r\nso total number of possible x are 8,16 i.e 2 values<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given a value = 35\r\nGiven b value = 8<\/pre>\n

Output:<\/strong><\/p>\n

The value of x such that given a%x==b {a,b = 35 8 } =  2<\/pre>\n

Program for Given two Numbers a and b Find all x Such that a % x = b in Python<\/h2>\n

Below are the ways to find all x such that given a % x = b in python:<\/p>\n