#include <stdio.h>
#ifndef TRUE
# define TRUE  1
# define FALSE 0
#endif

typedef struct IntList {
  int i;
  struct IntList* next;
  } intlist;

  int
  isprime (n, primes)
    int n;
    intlist* primes;
  {
    while (primes != NULL) {
      if (n % primes->i == 0)
        return FALSE;
      primes= primes->next;
    }
    return TRUE;
  }
  main ()
  {
    int n;
    intlist* primes= NULL;
    intlist* p;
    char* malloc();
  
    for (n= 3; ; n+= 2)
      if (isprime (n, primes)) {
        printf ("-> %d\n", n);
        p= (intlist*) malloc (sizeof (intlist));
        p->i= n;
        p->next= primes;
        primes= p;
      }
  }
