Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
150116_FactorialPrimo
//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 --> %20ld SÍ es PRIMO\n", n, factorial(n) - 1); } else { printf("%3ld --> %20ld NO es PRIMO\n", n, factorial(n) -1); } } return 0; } short esPrimoFactorial(long n) { return esPrimo(factorial(n) - 1); } long factorial(long n) { long F = 1; while(n) F *= n--; return F; } 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
Please
log in
to post a comment.
Project 3 Part 1 v1.2
sample.c
Struct
strend
Assignment 5 v2
quadsort vs quicksort
Intro coding hello world
Assignment 3
strcpy
recursive fundamentos
stackse - search stackoverflow differently
Please log in to post a comment.