﻿ search for prime factors
```/*****************************************************************************/
/*									     */
/*  SEARCH FOR PRIME FACTORS						     */
/*  11/14/06 (dkc)							     */
/*									     */
/*  Note: This subroutine is the same as "search.c" except the input table   */
/*  is of the type "short".                                                  */
/*									     */
/*****************************************************************************/
#include <stdio.h>
extern unsigned short table3[];
void quotient(unsigned int *a, unsigned int *q, unsigned int divisor);
void bigprod(unsigned int a0, unsigned int a1, unsigned int multiplier,
unsigned int *product);
unsigned int powquot(unsigned int a, unsigned int index);

unsigned int search(unsigned int *S, unsigned int k) {
unsigned int i,j,l,m,count;
unsigned int V[2],X[3];
count=0;
for (i=0; i<=k; i++) {
m=0;
l = (unsigned int)table3[i];
quotient(S, V, l);
bigprod(V[0], V[1], l, X);
if ((S[0]!=X[1]) || (S[1]!=X[2])) continue;
aloop:
m=m+1;
S[0]=V[0];
S[1]=V[1];
quotient(S, V, l);
bigprod(V[0], V[1], l, X);
if ((S[0]==X[1]) && (S[1]==X[2])) goto aloop;
j=powquot(m,0);
j=j+j+j;
if (j!=m)
return(0);
else
count=count+1;
if ((S[0]==0)&&(S[1]==1))
return(count);
}
if ((S[0]!=0)||(S[1]!=1))
return(0);
else
return(count);
}
```