Dec-06-2020, 06:19 PM
I am working on a program that can factor basic binomials. I am having trouble finding a way to verify if the result from 2 divided integers results in an integer. once I verify that, i then need to find a way to loop the code so that if it isn't an integer, it will restart the division with a new number, and if it is an integer, it will continue on with the program. (right now the program will get the guess right every now and then, as it runs off a random number generator to get the divisor, but it only gets it a small percentage of the time and i need a way for the program to automatically do this.)
print("Format - X + Ax + Bx ") num1 = input(" input A value - ") num2 = input(" input B value - ") inum1 = int(num1) inum2 = int(num2) import random divisor = int(random.randint(1,inum2)) value1 = inum2 / divisor value2 = inum2/value1 if value1 + value2 == inum1: print( "(X " + "+ " + str(value1) + ") " + "(X " + "+ " + str(value2) + ")" )