Home python Decide in the integers equation AX + B = 0

Decide in the integers equation AX + B = 0

Author

Date

Category

Task:

given numbers a and b. Decide in the integers equation Ax + B = 0. Display everything
integer solutions for this equation, if their number of course, output
the word “no” if there are no solutions, output the word “inf”, if integer
solutions infinitely a lot.

Input:
Two integers are introduced, not exceeding 30000 in absolute
Value.

Output:
Display the answer to the task.

Examples:

  1. Enter:

    6
    -2.
    

    Conclusion:

    no
    
  2. Enter:

    1
    -7.
    

    Conclusion:

    7
    

What is wrong with the code? It gives out that the answer is incorrect:

a = int (input ())
B = INT (INPUT ())
IF a! = B:
 IF B% a == 0:
  Print (-b // a)
 ELSE:
   PRINT ('NO')
 IF B == 0:
  PRINT ('INF')
ELSE:
 PRINT ('NO')

Answer 1, Authority 100%

a = int (input ())
B = INT (INPUT ())
if (a == 0 and b == 0):
  PRINT ('INF')
ELIF (A == 0 OR (B% A)! = 0):
  PRINT ('NO')
ELSE:
  Print (int (-b / a))

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions