[racket] How to verify prime numbers.
Hello,
Well, no one here is gonna do your homework!
You could start showing what you've done so far and asking more specific
doubts.
We are not code translation robots...
[]'s
Rodolfo Carvalho
2011/7/14 飞刀 <fly3ds at qq.com>
> Hello everyone,
>
> I want a program to verify prime numbers which can be runned in mzscheme.
> The following is C source. I don't konwn how to convert it to lisp.
>
> Thanks.
>
> #include <stdio.h>
> #include <time.h>
> #include <math.h>
> #include <string.h>
> #include <stdlib.h>
>
> #define E6 1000000
>
> char table[E6];
> int num = 0;
> //int prime[E8];
>
> void cal_table()
> {
> int j, k;
> time_t t1, t2;
> t1 = time(NULL);
> memset(table, 1, E6);
> for (j = 2 ; j < E6; j++) {
> if ( table[j] ) {
> num++;
> for ( k = j + j; k < E6; k += j )
> {
> table[k] = 0;
> }
> }
> }
> t2 = time(NULL);
> printf("Totaly %d primes until E6, cost %d time_t.\n", num, t2 - t1);
> }
>
> /*
> void init_prime()
> {
> int i;
> num = 0;
> printf("Init prime start...");
> for (i = 2; i < 2*E9; i++) {
> if (table[i])
> prime[num++] = i;
> }
> printf("Init prime finished...");
> }
> */
>
> int main()
> {
> int i;
> cal_table();
> //init_prime();
> return 0;
> }
>
>
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110714/387e7d46/attachment.html>