Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
20171127_ARRAY_PRIMOS
#include <stdio.h> #include <stdlib.h> #include <math.h> #define _T 100 short esPrimo(long n); int main() { long primos[_T]; long p; short i; for(i = 0 , p = 1 ; i < _T ; p++) { if(esPrimo(p)) { primos[i++] = p ;} } for(i = 0 ; i < _T ; i++) { if(i % 7 == 0) { printf("\n");} printf("%8ld", primos[i]); } printf("\n\n\n"); return 0; } short esPrimo(long n) { if(n % 2 == 0 && n != 2) { return 0; } long d; long lim = sqrt(n); for(d = 3 ; d <= lim ; d += 2) { if(n % d == 0) { return 0; } } return 1; }
run
|
edit
|
history
|
help
0
NOT a String in C
UserDefinedDataType_pointer1
Assignment 5 part 2 v2
acepta el reto 146
Ordered Openmp
Volume of sphere
Beginning linux
if (strcmp(abb, "lol")==0 || strcmp(abb, "LOL")==0 || )
Assignment 4 v3
20171116:FUNCIONES