Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
150109_RecursividadPrimo
//Title of this code //gcc 4.8.2 #include <stdio.h> #include <math.h> short esPrimo(long p); long siguientePrimo(long p); short esCompuesto(long p); int main(void) { long p = 49; if(esPrimo(p)) { printf("%ld SÍ es PRIMO\n\n\n", p); } else { printf("%ld NO es PRIMO\n\n\n", p); } return 0; } short esPrimo(long p) { if(p == 1 || p == 2) return 1; long d; for(d = 2 ; d <= sqrt(p) && p % d ; d = siguientePrimo(d)); return p % d; } long siguientePrimo(long p) { do { p++; }while(esCompuesto(p)); return p; } short esCompuesto(long p) { return !esPrimo(p); }
run
|
edit
|
history
|
help
0
2.1.3 Sum of squares of first hundred natural numbers with different cores
c
left significant peace as unison real manual user
main.c
Square pyramid
PART 2
PRACTICA LISTA
Perfect number
Basic String Compression in C
C)_Assign_q4