int main(){ long long int x, y; memset(rfat, 0, sizeof(rfat)); while(scanf("%lld %lld", &x, &y) != EOF) printf("%lld\n", fat(x) + fat(y)); return 0; }
int main (void) { int N,P,S; scanf("%d%d",&N,&P); S=(fat(N)/(fat(P)*fat(N-P))); printf("S=%d\n",S); return 0; }
int main() { long long int n; long long int m; long long int fatsum; scanf("%lli", &n); printf("Fatorial de n: %lli\n", fat(n)); scanf("%lli", &m); printf("Fatorial de m: %lli\n", fat(m)); fatsum= fat(n) + fat(m); printf("Soma fatorial: %lli\n", fatsum); return 0; }
void main() { int num; printf("Digite um numero: "); scanf("%d",&num); printf("%d! = %d",num,fat(num)); }
int formula(int *num) { double e = 1; for (int i = 1; i <= *num; i++) { e += 1.0 / fat(&i); } printf("%.10f\n", e); }
main() { /* vars */ int a[T], b[T], i; printf("FATORIAL DE UM VETOR\n\n"); /* Entrada */ printf("Carregando um vetor de %i elementos...\n", T); for (i = 0; i < T; i++) { printf("Digite a[%d]: ", i); scanf("%i", &a[i]); } /* Processamento */ fat(a, b); /* Saída */ printf("\na:\n"); for (i = 0; i < T; i++) { printf("%i ", a[i]); } printf("\n\nb:\n"); for (i = 0; i < T; i++) { printf("%i ", b[i]); } printf("\n"); }
void proded_perm(argom* arg) { int i,k; int app,proded=1; if(arg->index >= 1) { for(k=arg->index; k >= 0; k--) { app=arg->elementi[k]; arg->elementi[k]=arg->elementi[arg->index]; arg->elementi[arg->index] = app; arg->index--; proded_perm(arg); arg->index++; app=arg->elementi[k]; arg->elementi[k]=arg->elementi[arg->index]; arg->elementi[arg->index] = app; } } else if(2*arg->nperm==fat(arg->dim) && arg->dim!=1) pthread_exit(0); else { arg->nperm++; for(i=0; i < arg->dim; i++) proded=proded*arg->mat[i][arg->elementi[i]-1]; if(classe(arg->elementi , arg->dim)%2!=0) proded=-proded; *arg->det=*arg->det+proded; } }
//Auxiliary functions long double fat(long double n){ if(n==0){ return 1; } return fat(n-1)*n; }
int main () { int n,k,x; int aux; printf ("Escreva dois números inteiros a para eu calcular a combinação deles: "); scanf ("%d %d", &n, &k); if (n<k) { aux=n; n=k; k=aux; } x=n-k; printf ("O valor dessa combinação é %d", fat(n)/fat(k)*fat(x)); return 0; }
int fat (int n){ if (n >1){ return n*fat(n-1); } else return 1; }
int main() { unsigned short a; a = 5; a = fat(a, 8); printf("%d\n", a); return 0; }
bool VFAT::build(const char* path, int extra_MB) { dataSectors = 0; currVirtPath = ""; currPath = path; list_files(path, count_ListCallback); dataSectors += 8; //a few for reserved sectors, etc. dataSectors += extra_MB*1024*1024/512; //add extra write space //dataSectors += 16*1024*1024/512; //add 16MB worth of write space. this is probably enough for anyone, but maybe it should be configurable. //we could always suggest to users to add a big file to their directory to overwrite (that would cause the image to get padded) //this seems to be the minimum size that will turn into a solid fat32 if(dataSectors<36*1024*1024/512) dataSectors = 36*1024*1024/512; if(dataSectors>=(0x80000000>>9)) { printf("error allocating memory for fat (%d KBytes)\n",(dataSectors*512)/1024); printf("total fat sizes > 2GB are never going to work\n"); } delete file; try { file = new EMUFILE_MEMORY(dataSectors*512); } catch(std::bad_alloc) { printf("error allocating memory for fat (%d KBytes)\n",(dataSectors*512)/1024); printf("(out of memory)\n"); return false; } //debug.. //file = new EMUFILE_FILE("c:\\temp.ima","rb+"); //format the disk { EmuFat fat(file); EmuFatVolume vol; u8 ok = vol.init(&fat); vol.formatNew(dataSectors); //ensure we are working in memory, just in case we were testing with a disk file. //libfat will need to go straight to memory (for now; we could easily change it to work with the disk) file = file->memwrap(); } EMUFILE_MEMORY* memf = (EMUFILE_MEMORY*)file; //setup libfat and write all the files through it LIBFAT::Init(memf->buf(),memf->size()); list_files(path, build_ListCallback); LIBFAT::Shutdown(); return true; }
long long int fat(long long int n){ if (rfat[n] != 0) return rfat[n]; if (n <= 1) rfat[n] = 1; else rfat[n] = n * fat(n - 1); return rfat[n]; }
double seno(double x){ double sen=x; int n2=1; for(int n=3;n<20;n=n+2){ sen+=(potint(-1,n2))*(potint(x,n)/fat(n)); n2++; } return sen; }
int main() { int a, i=1; while (i>0){ scanf("%d", &a); if(a>=0){ printf("%d %d\n", fib(a), fat(a));} else { break;} }}
int main1(void) { int n = 0; printf("informe o valor para ser fatorado: "); fflush(stdout); scanf("%d", &n); printf("%d.", fat(n)); return 0; }
main() { int n, resp; printf("Digite o valor de n: "); scanf("%d",&n); resp = fat(n); printf("%d",resp); getch(); }
main() { int i,num; do { //laco enquanto nao for positivo nao continua printf("\nDigite um numero inteiro positivo:"); scanf("%d", &num); } while(num<0); for (i=0; i<=num; i++) { //modtra TODOS os fatoriais de 1 ate num printf("\nFatorial de %d eh: %g", i, fat(i)); } getch(); }
int main(){ int x; scanf("%d",&x); int aux = fat(x); printf("%d",aux); getch(); return 0; }
int fat(int n) { if(0 == n || 1 == n) { return 1; } else { return n * fat(n - 1); } }
void perc(argom* arg) { unsigned long long totperm; totperm=fat(arg->dim); printf("\n"); printf("\r%.2f%% completato.",200*(float)arg->nperm/totperm); while(2*arg->nperm<totperm) { printf("\r%.2f%% ", 200*(float)arg->nperm/totperm); usleep(5000); } printf("\r "); }
void print_sin(double ang) { int i, sig = 1; double aux, result = 0; for (i = 1; i < 10; i += 2) { aux = pow(ang, i)/fat(i); result += sig*aux; sig = -sig; } printf("%lf\n", result); }
main() { int n ; printf("Digite o valor de n: "); scanf("%d",&n); /* resp = fat(n); printf("%d",resp); não é necessário criar uma variavel para armazenar o valor do resultado da funcao. O retorno colocado direto no printf já retorna o resultado */ printf("%d", fat(n)); getch(); }
int main() { int num; double result; printf("\nEntre com o numero:"); scanf("%d", &num); result = fat(num); printf("\nO fatorial de %d = %f\n", num, result); return 0; }
void CTypetestDlg::OnPaint() { CPaintDC dc(this); // device context for painting // Switch to metric coordinates dc.SetMapMode(MM_LOMETRIC); // Fill the square with colour CBrush yellow(RGB(0xFF,0xFF, 0xC0)); // Light yellow dc.FillRect(CRect(100, -100, 600, -600), &yellow); int x = 100; for (int i=0; i <= 10; i++) { dc.MoveTo(x, -600); dc.LineTo(700-x, -100); // Now x is used in the y direction dc.MoveTo(100, -x); dc.LineTo(600, -(700-x)); x += 50; } CPen fat(PS_SOLID, 30, RGB(255, 0, 0)); // Fat red pen CPen* oldPen = dc.SelectObject(&fat); dc.MoveTo(100, -100); dc.LineTo(100, -600); dc.LineTo(600, -600); dc.LineTo(600, -100); dc.LineTo(100, -100); dc.SelectObject(&oldPen); char* szFading = "Fading..."; x = 700; int y = -600; float size = 500; dc.SetTextAlign(TA_BASELINE); dc.SetBkMode(TRANSPARENT); for (int j=0; j < 9; j++) { CFont arial; arial.CreateFont((int)-size, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VARIABLE_PITCH | FF_SWISS, "Arial"); CFont* oldFont = dc.SelectObject(&arial); dc.TextOut(x, y, szFading+j, 1); CSize szExtent = dc.GetTextExtent(szFading+j, 1); x += szExtent.cx; dc.SelectObject(&oldFont); size *= 0.8f; // Next char only 80% as large } }
double combinacao(int n, int p){ double resposta; resposta = fat(n)/(fat(p)*fat(n-p)); return resposta; //return fat(n)/(fat(p)*fat(n-p)); }
int main (void) { printf("%d\n", fat(4)); return 0; }
int fat(int *num) { if (*num == 1) return(1); return(fat(*num - 1) * *num); }
int main() { int n = fat(3); return 0; }
void InlineWatchpointSet::freeFat() { ASSERT(isFat()); fat()->deref(); }