Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

CuTee Simple factorial

  1. Apr 15, 2006 #1
    PHP:
    #include<qvalidator.h>
    //int input;

    void Factor::init(){
        InputEdit->setValidator(new QDoubleValidator(InputEdit));

        FactorNumber();
        InputEdit->selectAll();
    }

    int Factor::factorials(int n){
        if(n<=1) return 1;
        FactorialDisplay->setText(QString::number(n*factorials(n-1),1));
        return n*factorials(n-1);
    }

    void Factor::FactorNumber()
    {
        int input=InputEdit->text().toDouble();
        factorials(input);  
    }
    *** 2 edit boxes: InputEdit for input number; FactorialDisplay to display factor "in action"
    *** 1 button called FactorButton implements factorNumber() connecting to the main form named Factor.

    No errors but program run wild when unfactorable number is used and my text edit box does display factoring process till input equals 1

    Help me with this little problme plz.
    Thanks
     
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted