def testClicked(self): try: # Make sure inputs are valid integers n = int(self.input_n.text()) k = int(self.input_k.text()) # This is the call to the pass-through function that gets your results, from # both the Fermat and Miller-Rabin tests you will implement ret_fermat, ret_mr = fermat.prime_test(n, k) # Output results from Fermat and compute the appropriate error bound, if necessary if ret_fermat == 'prime': prob = fermat.fprobability(k) self.outputF.setText( '<i>Fermat Result:</i> {:d} <b>is prime</b> with probability {:5.15f}'.format(n, prob)) else: # Should be 'composite' self.outputF.setText('<i>Fermat Result:</i> {:d} is <b>not prime</b>'.format(n)) # Output results from Miller-Rabin and compute the appropriate error bound, if necessary if ret_mr == 'prime': prob = fermat.mprobability(k) self.outputMR.setText( '<i>MR Result:</i> {:d} <b>is prime</b> with probability {:5.15f}'.format(n, prob)) else: # Should be 'composite' self.outputMR.setText('<i>MR Result:</i> {:d} is <b>not prime</b>'.format(n)) # If inputs not valid, display an error except Exception as e: self.outputF.setText('<i>ERROR:</i> ' + str(e))
def testClicked(self): try: # Make sure inputs are valid integers n = int(self.input_n.text()) k = int(self.input_k.text()) result = fermat.prime_test(n, k) if result == 'prime': prob = fermat.probability(k) self.output.setText( '<i>Result:</i> {:d} <b>is prime</b> with probability {:5.5f}.' .format(n, prob)) elif result == 'carmichael': self.output.setText( '<i>Result:</i> {:d} is a <b>Carmichael number</b>.'. format(n)) else: # Should be 'composite' self.output.setText( '<i>Result:</i> {:d} is <b>not prime</b>.'.format(n)) # If inputs not valid, display an error except Exception as e: self.output.setText('<i>ERROR:</i> inputs must be integers!') print(str(e))
def testClicked( self ): try: # Make sure inputs are valid integers n = int( self.input_n.text() ) k = int( self.input_k.text() ) result = fermat.prime_test(n,k) if result == 'prime': prob = fermat.probability(n,k) self.output.setText( '<i>Result:</i> {:d} <b>is prime</b> with probability {:5.5f}.'.format(n,prob) ) elif result == 'carmichael': self.output.setText('<i>Result:</i> {:d} is a <b>Carmichael number</b>.'.format(n)) else: # Should be 'composite' self.output.setText('<i>Result:</i> {:d} is <b>not prime</b>.'.format(n)) # If inputs not valid, display an error except Exception as e: self.output.setText('<i>ERROR:</i> inputs must be integers!')
def testClicked(self): try: # Make sure inputs are valid integers n = int(self.input_n.text()) k = int(self.input_k.text()) # result = fermat.prime_test(n,k) ret_fermat, ret_mr = fermat.prime_test(n, k) # if result == 'prime': # prob = fermat.probability(k) # self.output.setText( '<i>Result:</i> {:d} <b>is prime</b> with probability {:5.15f}'.format(n,prob) ) # elif result == 'carmichael': # self.output.setText('<i>Result:</i> {:d} is not prime because it is a <b>Carmichael number</b>'.format(n)) # else: # Should be 'composite' # self.output.setText('<i>Result:</i> {:d} is <b>not prime</b>'.format(n)) if ret_fermat == 'prime': prob = fermat.fprobability(k) self.outputF.setText( '<i>Fermat Result:</i> {:d} <b>is prime</b> with probability {:5.15f}' .format(n, prob)) else: # Should be 'composite' self.outputF.setText( '<i>Fermat Result:</i> {:d} is <b>not prime</b>'.format(n)) # Output results from Miller-Rabin and compute the appropriate error bound, if necessary if ret_mr == 'prime': prob = fermat.mprobability(k) self.outputMR.setText( '<i>MR Result:</i> {:d} <b>is prime</b> with probability {:5.15f}' .format(n, prob)) else: # Should be 'composite' self.outputMR.setText( '<i>MR Result:</i> {:d} is <b>not prime</b>'.format(n)) # If inputs not valid, display an error except Exception as e: # self.output.setText('<i>ERROR:</i> inputs must be integers!') self.outputF.setText('<i>ERROR:</i> ' + str(e))