summaryrefslogblamecommitdiff
path: root/src/user/app/prime/main.c
blob: d9b60ab8c4c161c476b1f9c7a1dea68dfed1c739 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                         
                                 







                                                          
#include <stdio.h>

int is_prime(int i) {
	int j;
	for (j = 2; j*j <= i; j++) {
		if (i % j == 0) return 0;
	}
	return 1;
}

int main(int argc, char **args) {
	int i;
	for (i = 2; i < 1000000; i++) {
		if (is_prime(i)) printf("%d\t", i);
	}
	printf("\nThat's all prime numbers for today.\n");

	return 0;
}