C++ (Qt)#include <math.h> QString str2;double t_otv,n; void Form2::pb() { n=lineEdit10->text().toDouble(); t_otv=fact(n); str2.setNum(t_otv); } int Form2::fact(double n) { double ret=1; double zdoub; int j; zdoub=1; if (n==0) ret=1; else for(j=1; j<=n; j++) { ret=ret*zdoub; zdoub++; } return ret; }
double f(double x){ return x?f(x-1)*x:1;}
double f(double x){ if (x < 0) return FALSE; return x?f(x-1)*x:1;}