Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C_141210_Funciones
//Title of this code #include <stdio.h> #include <math.h> long factorial(short a); short mcd(short a, short b); short esPrimo(long p); int main(void) { short n; short a, b; long p; printf("Valor de n ... "); scanf(" %hd", &n); printf("\n\nEl factorial de %hd es %ld\n\n", n, factorial(n)); printf("Valor de a ... "); scanf(" %hd", &a); printf("Valor de b ... "); scanf(" %hd", &b); printf("\n\nEl mcd de %hd y %hd es %hd\n\n", a, b, mcd(a, b)); printf("Valor de n ... "); scanf(" %ld", &p); if(esPrimo(p)) printf("\n\n%ld es PRIMO\n", p); else printf("\n\n%ld No es PRIMO\n", p); for(n = 0 ; n < 20 ; n++) { printf("%3hd --> %25ld\n", n, factorial(n)); } return 0; } long factorial(short a) { long F = 1; while(a) F *= a--; return F; } short mcd(short a, short b) { while(b) { short aux = a; a = b; b = aux % b; } return a; } short esPrimo(long p) { if(p == 1 || p == 2) return 1; short d; for(d = 2 ; d <= sqrt(p) && p % d ; d++); return p % d; }
run
|
edit
|
history
|
help
0
Función quicksort decreciente
300
finalpyramid
Matrix multiplication. C
1, 2, 3, & 4-layer neural networks in C
day 2
Sheldon 9 area none aliens as aliens and farms Lockheed Kelly and lame lead district 9
AVANCE 1 TAREA M4 - PERLAS
ALPAHABET PATTERNS
Double data type.c