Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
150116_PrimoFactorial
//Title of this code //gcc 4.8.2 #include <stdio.h> #include <math.h> short esPrimoFactorial(long n); long factorial(long n); short esPrimo(long n); int main(void) { long n; for(n = 0 ; n < 20 ; n++) { if(esPrimoFactorial(n)) { printf("%3ld --> %25ld SÍ es PRIMO.\n", n, factorial(n) - 1); } else { printf("%3ld --> %25ld NO es PRIMO.\n", n, factorial(n) - 1); } } return 0; } short esPrimoFactorial(long n) { return esPrimo(factorial(n) - 1); } long factorial(long n) { return n ? n * factorial(n - 1) : 1; } short esPrimo(long n) { if(n <= 2) return 1; long d; for(d = 2 ; d <= sqrt(n) && n % d ; d++); return n % d; }
run
|
edit
|
history
|
help
0
A.c
B_141212_IntercambiarPunteros
prime numbers using functions
18BCE2182 MIDTERM PART-B CRITICAL
a1
DIGITOS DE U. A DECENAS
pattern 12
bitwise operations
lab5!
WrongWay reversible iterator Copyright(C) 2016 Henry Kroll III www.thenerdshow.com