/*
   gematria.c (Gematria Calculator)
   Version 1.0 930616 e.v.
   (c) 1993 Fr. Ex Nihilo Duo Fit (shawnb@cscihp.ecst.csuchico.edu)
   This software may be distributed freely, but only in an unmodified form.

   93,

   My intention for writing this program was to help novice Qabalists a
   little with the intricities of gematriac analysis.  However, as you
   may be able to see, this is not a database.  I had no intention of
   typing in the entire Sepher Sephiroth.  By the way, Crowley's book is
   indispensable for work of this sort.  Do yourself a favor and go out
   and buy _777 and other Qabalistic Writings of Aleister Crowley_ (Weiser,
   1972.)  Hope some of you find this useful.

   93 93/93.

   Fr. E.N.D.F.

   Compile with: gcc -traditional -O2 gematria.c -o gematria  	

   "Divide, add, multiply, and understand!" - Liber CCXX 1.25
*/

#include 
#define MAXFACT 10

main(int argc, char *argv[])
{
  int sum = 0;
  int i = 1;
  int factcount = 0;
  int primeflag = 1;
  int fact[MAXFACT];
 
  if((argc == 2)&&(*++argv[1] == 'h')) {
    printf("Usage: gematria -[ha] string\n");
    printf("where -a is for hebrew analysis.\n");
    exit(0);  
  }	    
   
  if((argc == 3)&&(*++argv[1] == 'a')) {
    *--argv[2];
    while(*++argv[2] != NULL) {
      if(*argv[2] == 'A') {
	sum += 1;
	continue;
      }
      else if(*argv[2] == 'B') {
	sum += 2;
	continue;
      }
      else if(*argv[2] == 'G') {
	sum += 3;
	continue;
      }
      else if(*argv[2] == 'D') {
	sum += 4;
	continue;
      }
      else if((*argv[2] == 'H')||(*argv[2] == 'E')) {
	sum += 5;
	continue;
      }
      else if((*argv[2] == 'V')||(*argv[2] == 'U')) {
        sum += 6;
	continue;
      }
      else if(*argv[2] == 'Z') {
	sum += 7;
	continue;
      }
      else if(*argv[2] == 'C') {
	if (*++argv[2] == 'h') {
	  sum += 8;
	  continue;
	}
	*--argv[2];
      }
      else if(*argv[2] == 'T') {
	if(*++argv[2] == 'h') {
	  sum += 400;
	  continue;
	}
	if(*argv[2] == 's') {
	  sum += 90;
	  continue;
	}
	*--argv[2];
	sum += 9;
	continue;
      }
      else if((*argv[2] == 'Y')||(*argv[2] == 'I')||(*argv[2] == 'J')) {
	sum += 10;
	continue;
      }
      else if(*argv[2] == 'K') {
	sum += 20;
	continue;
      }
      else if(*argv[2] == 'L') {
	sum += 30;
	continue;
      }
      else if(*argv[2] == 'M') {
	sum += 40;
	continue;
      }
      else if(*argv[2] == 'N') {
	sum += 50;
	continue;
      }
      else if(*argv[2] == 'S') {
	if(*++argv[2] == 'h') {
	  sum += 300;
	  continue;
	}
	*--argv[2];
	sum += 60;
	continue;
      }
      else if(*argv[2] == 'O') {
	sum += 70;
	continue;
      }
      else if((*argv[2] == 'P')||(*argv[2] == 'F')) {
	sum += 80;
	continue;
      }
      else if(*argv[2] == 'Q') {
	sum += 100;
	continue;
      }
      else if(*argv[2] == 'R') {
	sum += 200;
	continue;
      }
      else {
	printf("%c is an illegal character, try re-spelling.\n", *argv[2]);
	exit(1);
      }
    }
  printf("The corresponding gematria is %d.\n", sum);

  while(++i < sum) {
    if(sum%i == 0) {
       if(primetest(i) == 1) {
         factcount++;
         fact[factcount] = i;
       }
       primeflag = 0;
    }
  }
  
  if(primeflag == 1) {
    printf("The number %d is prime.\n", sum);
  }
    
  if(primeflag == 0) {
    printf("%d has the following prime factors: ", sum);
    for(i=1; i<= factcount; i++) {
      printf("%d ", fact[i]);
    }
    printf("\n");
  }
  exit(0);  
  }

  if(argc == 1) {
    printf("Gematria Calculator 1.0\n");
    printf("(c) 1993 Fr. Ex Nihilo Duo Fit\n");
    printf("For a usage summary type gematria -h\n");
  }

  else {
   printf("Invalid usage.\n");
   printf("For a usage summary type gematria -h\n");
  }
}

int primetest(int k)
{
  int j=1;
  while(++j
         

Disclaimer: The file contained in the box above or displayed in a separate window from a link in the box above is NOT owned nor implied to be owned by BeYoND THe iLLuSioN. Most files at BeYoND THe iLLuSioN are originally from public Bulletin Board Systems (BBS) which were popular in the days before the Internet or from gopher, web, and FTP sites from the early days of the Internet which no longer exist today. Essentially, all files were acquired from the public domain in one for or another.

However, there have been occasions when copyright protected material has appeared on BeYoND THe iLLuSIoN without permission of the copyright holder. In these instances, we have and will continue to remove the copyright protected file as soon as it is brought to our attention. This can now be done using our Report Copyright Material form. Fill out the form, and the webmaster will be notified of the situation.

There are also times when files found on BeYoND THe iLLuSioN have a real home somewhere else on the Internet. In these instances, we will gladly replace the file with a link to its true home whenever it is brought to our attention. If you know of the true home of any of these files, you can use our Report Original URL form to bring it yo our attention.