```/******************************************************************************/
/*									      */
/* COMPUTE 3N+1 OR 3N-1 SEQUENCES (GENERALIZED DEAD LIMBS)		      */
/* 02/09/11 (dkc)							      */
/*									      */
/* This C program computes general 3n+1 or 3n-1 sequences. The fourth-to-last */
/* element of a sub-sequence must be odd and the third-to-last element of     */
/* a sub-sequence must be divisible by 8. The fourth-to-last element must     */
/* be larger than the order divided by 6. Certain lengths of such sequences   */
/* are not permissible.  General 3n+c sequences with the same properties are  */
/* also computed for c=5, 7, 11, 13, 17, 19, 23, 25, and 29 (where n>0).      */
/*									      */
/* The number of even and odd elements in the segment are computed (where the */
/* element after an odd element i is defined to be (3i+c)/2).		      */
/*									      */
/******************************************************************************/
#include <stdio.h>
#include <math.h>
extern char *malloc();
int main () {
//
int c=5; // c
unsigned int row=0;
unsigned int nozero=0;
unsigned int iters=1; // segment count
unsigned int iters1=1; // segment count (normally set to "iters" value)
//
unsigned int v[32768],itero,itere;
unsigned int a,b,f,g,h,i,j,k,m,n,np,order,oddk,count; // indices
unsigned int index,delta;
unsigned int he[2048],ho[2048*4]; // histogram
unsigned int c1[50],c2[50],c3[50],c4[50],c5[50],c6[50],c7[50],c8[50],c9[50];
unsigned int c1ind,c2ind,c3ind,c4ind,c5ind,c6ind,c7ind,c8ind,c9ind,c5cnt,c5tot,c11cnt,c11tot;
unsigned int c13cnt,c13tot,c17cnt,c17tot,c19cnt,c19tot,c23cnt,c23tot,c25cnt,c25tot,c29cnt,c29tot;
unsigned int c17cyc1,c17cyc2,c17cyc3,c5cyc1,c5cyc2,c5cyc3;
unsigned int c11cyc1,c13cyc1,c13cyc2,c13cyc3,c13cyc4,c13cyc5,c13cyc6,c1cyc1;
unsigned int c19cyc1,c23cyc1,c23cyc2,c23cyc3,c25cyc1,c25cyc2,c25cyc3;
unsigned int c29cyc1,c29cyc2,c29cyc3,c29cyc4,c29cyc5,c29cyc6,c29cyc7,c29cyc8;
unsigned int c29cyc9,c29cyc10,c29cyc11,c29cyc12,c29cyc13,c29cyc14,c7cyc1,c7cnt,c7tot,extra[10];
unsigned int y[178]={
0,3,6,8,11,  // I (invalid lengths)
13,16,19,21,24, // I
26,29,32,34,37, // I
39,42,44,47,50, // J
52,55,57,60,63, // J
65,68,70,73,75, // K
78,81,83,86,88, // K
91,94,96,99,101, // K
104,106,109,112,114, // L
117,119,122,125,127, // L
130,132,135,138,140, // L
143,145,148,150,153, // M
156,158,161,163,166, // M
171,174,176,179, // M
184,187,189,192,194, // I'
197,200,202,205,207, // I'
210,212,215,218,220, // J'
223,225,228,231,233, // J'
236,238,241,243,246, // K'
249,251,254,256,259, // K'
262,264,267,269,272, // K'
275,277,280,282,285, // K'
287,290,293,295,298, // L'
300,303,306,308,311, // L'
313,316,318,321,324, // M'
326,329,331,334,337, // M'
339,342,344,347,349, // N
352,355,357,360,362, // N
365,368,370,373,375, // N
378,380,383,386,388, // O
391,393,396,399,401, // O
404,406,409,412,414, // O
417,419,422,424,427, // P
430,432,435,437,440, // P
443,445,448,450,453, // P
458,461,463,466}; //
unsigned int z[75]={
1,9, // I  (first elements of length pairs which
14,22, // I when decremented by 3 give invalid
27,35, // I lengths)
40,45, // J
53,58, // J
66,71,76, // K
84,89, // K
97,102, // K
107,115, // L
120,128, // L
133,141, // L
146,151, // M
159,164, // M
172,177, // M
182,190, // I'
195,203, // I'
208,213, // J'
221,226, // J'
234,239,244, // K'
252,257, // K'
265,270, // K'
278,283, // K'
288,296, // L'
301,309, // L'
314,319, // M'
327,332, // M'
340,345,350, // N
358,363, // N
371,376, // N
384,389, // O
394,402, // O
407,415, // O
420,428, // P
433,438, // P
446,451, // P
459,464}; //
unsigned int table[121*2]={
0, 0, // 0
4, 3, // 1
5, 4, // 2 (6, 2) => (3, 2)
5, 4, // 3 (7, 3) => (5, 3)
6, 5, // 4
6, 5, // 5 (10, 5) => (8, 5)
7, 6, // 6
8, 7, // 7 (14, 7) => (11, 7)
8, 7, // 8
9, 8, // 9
9, 8, // 10
10, 9, // 11
11, 10, // 12 (22, 12) => (19, 12)
11, 10, // 13
12, 11, // 14
12, 11, // 15
13, 12, // 16
13, 12, // 17 (29, 17) => (27, 17)
14, 13, // 18
15, 14, // 19
15, 14, // 20
16, 15, // 21
16, 15, // 22
17, 16, // 23
18, 17, // 24
18, 17, // 25
19, 18, // 26
19, 18, // 27
20, 19, // 28
20, 19, // 29 (48, 29) => (46, 29)
21, 20, // 30
22, 21, // 31
22, 21, // 32
23, 22, // 33
23, 22, // 34
24, 23, // 35
25, 24, // 36
25, 24, // 37
26, 25, // 38
26, 25, // 39
27, 26, // 40
27, 26, // 41 (67, 41) => (65, 41)
28, 27, // 42
29, 28, // 43
29, 28, // 44
30, 29, // 45
30, 29, // 46
31, 30, // 47
32, 31, // 48
32, 31, // 49
33, 32, // 50
33, 32, // 51
34, 33, // 52
35, 34, // 53 (87, 53) => (84, 53) Note: Even count was the same ((34, 34)) (for c=1 or -1)
35, 34, // 54
36, 35, // 55
36, 35, // 56
37, 36, // 57
37, 36, // 58
38, 37, // 59
39, 38, // 60
39, 38, // 61
40, 39, // 62
40, 39, // 63
41, 40, // 64
42, 41, // 65
42, 41, // 66
43, 42, // 67
43, 42, // 68
44, 43, // 69
44, 43, // 70
45, 44, // 71
46, 45, // 72
46, 45, // 73
47, 46, // 74
47, 46, // 75
48, 47, // 76
49, 48, // 77
49, 48, // 78
50, 49, // 79
50, 49, // 80
51, 50, // 81
51, 50, // 82
52, 51, // 83
53, 52, // 84
53, 52, // 85
54, 53, // 86
54, 53, // 87
55, 54, // 88
56, 55, // 89
56, 55, // 90
57, 56, // 91
57, 56, // 92
58, 57, // 93
58, 57, // 94
59, 58, // 95
60, 59, // 96
60, 59, // 97
61, 60, // 98
61, 60, // 99
62, 61, // 100
63, 62, // 101
63, 62, // 102
64, 63, // 103
64, 63, // 104
65, 64, // 105
66, 65, // 106  // (0,65) for c=1 or -1
66, 65, // 107
67, 66, // 108
67, 66, // 109
68, 67, // 110
68, 67, // 111  // exception for c=17 (69)
69, 68, // 112
70, 69, // 113
70, 69, // 114
71, 70, // 115
71, 70, // 116
72, 71, // 117
72, 0, // 118
73, 72, // 119
74, 73}; // 120
unsigned int *table1;
FILE *Outfp;
Outfp = fopen("out2a.dat","w");
table1=(unsigned int*) malloc(800008);
if (table==NULL) {
printf("error: not enough memory \n");
goto zskip;
}
if (iters1>iters) {
printf("Error: Second number of iterations too large. \n");
goto zskip;
}
if ((row!=0)&&(iters==iters1)) {
printf("row must equal zero \n");
goto zskip;
}
if ((row==0)&&(iters!=iters1)) {
printf("row must not equal zero \n");
goto zskip;
}
for (i=0; i<2048; i++) { // clear histogram of lengths
he[i]=0; // for limbs ending in E
}
for (i=0; i<2048*4; i++) { // clear histogram of lengths
ho[i]=0;
}
for (i=0; i<50; i++) {
c1[i]=0;
c2[i]=0;
c3[i]=0;
c4[i]=0;
c5[i]=0;
c6[i]=0;
c7[i]=0;
c8[i]=0;
c9[i]=0;
}
for (i=0; i<10; i++)
extra[i]=0;
c1ind=0;
c2ind=0;
c3ind=0;
c4ind=0;
c5ind=0;
c6ind=0;
c7ind=0;
c8ind=0;
c9ind=0;
c5cnt=0;
c5tot=0;
c5tot=0;
c7cnt=0;
c7tot=0;
c11cnt=0;
c11tot=0;
c13cnt=0;
c13tot=0;
c17cnt=0;
c17tot=0;
c19cnt=0;
c19tot=0;
c23cnt=0;
c23tot=0;
c25cnt=0;
c25tot=0;
c29cnt=0;
c29tot=0;
c1cyc1=0;
c5cyc1=0;
c5cyc2=0;
c5cyc3=0;
c7cyc1=0;
c11cyc1=0;
c13cyc1=0;
c13cyc2=0;
c13cyc3=0;
c13cyc4=0;
c13cyc5=0;
c13cyc6=0;
c17cyc1=0;
c17cyc2=0;
c17cyc3=0;
c19cyc1=0;
c23cyc1=0;
c23cyc2=0;
c23cyc3=0;
c25cyc1=0;
c25cyc2=0;
c25cyc3=0;
c29cyc1=0;
c29cyc2=0;
c29cyc3=0;
c29cyc4=0;
c29cyc5=0;
c29cyc6=0;
c29cyc7=0;
c29cyc8=0;
c29cyc9=0;
c29cyc10=0;
c29cyc11=0;
c29cyc12=0;
c29cyc13=0;
c29cyc14=0;
//
// DEAD LIMBS (ending in an even natural number)//
count=0;
index=0;
for (i=99999999; i>3; i-=6) {
if ((c==5)&&((i/5)*5==i))
continue;
if ((c==7)&&((i/7)*7==i))
continue;
if ((c==11)&&((i/11)*11==i))
continue;
if ((c==-11)&&((i/11)*11==i))
continue;
if ((c==13)&&((i/13)*13==i))
continue;
if ((c==17)&&((i/17)*17==i))
continue;
if ((c==19)&&((i/19)*19==i))
continue;
if ((c==23)&&((i/23)*23==i))
continue;
if ((c==25)&&((i/5)*5==i))
continue;
if ((c==29)&&((i/29)*29==i))
continue;
g=0;
k=i; // set k
v[0]=k;
n=1;
order=3; // set order
while (order<k)
order=order*2;
aloop:
if (k>0x30000000) {
//      printf("error: k=%d \n",k);
goto cskip;
}
oddk=k;
k=3*k+c; // next sequence value
v[n]=k;
n=n+1; // increment element count
if (n>32767) {
printf("error 1: v array too small %d %d %d %d \n",v[0],v[1],v[2],v[32767]);
goto zskip;
}
while (order<k)
order=order*2;
if (k==(k/8)*8) { // check for connection point
g=g+1;
if (g<iters)
goto dskip;
if (g>iters)
goto cskip;
np=n+1; // increment element count
m=i;
while (m<(order/2)) {
m=m*2;
np=np+1;
}
if (oddk>(order/6)) {
count=count+1;
itero=0;
itere=0;
f=0;
for (h=0; h<n; h++) {
if ((v[h]&1)==1)
itero=itero+1;
else {
if ((v[h-1]&1)==0)
itere=itere+1;
}
if (((v[h]&1)==1)&&(v[h+1]==(v[h+1]/8)*8))
f=f+1;
if (f==iters1) {
//	       printf(" order=%d h=%d, %d %d %d \n",order,h,v[0],v[h],np-n);
//	       printf(" order=%d n=%d, %d %d %d \n",order,n,v[0],v[n-1],np-n);
goto wskip;
}
}
goto zskip;
wskip:	 itere=itere+(np-n)+1;
if (itero<121) {
a=table[2*itero];
b=table[2*itero+1];
if (iters==iters1) {
if ((c==29)&&((v[n-1]==392)||(v[n-1]==176)||(v[n-1]==3154208)||(v[n-1]==295736)||(v[n-1]==166424)&&(v[n-1]==166424)||(v[n-1]==316328)||(v[n-1]==75176)||(v[n-1]==777464)||
(v[n-1]==6831320)||(v[n-1]==5764064)||(v[n-1]==2308928)||(v[n-1]==81224)&&(v[n-1]==30488)||(v[n-1]==147608))) {
if (v[n-1]==392)
c29cyc1=c29cyc1+1;
if (v[n-1]==176)
c29cyc2=c29cyc2+1;
if (v[n-1]==3154208)
c29cyc3=c29cyc3+1;
if (v[n-1]==295736)
c29cyc4=c29cyc4+1;
if (v[n-1]==166424)
c29cyc5=c29cyc5+1;
if (v[n-1]==316328)
c29cyc6=c29cyc6+1;
if (v[n-1]==75176)
c29cyc7=c29cyc7+1;
if (v[n-1]==777464)
c29cyc8=c29cyc8+1;
if (v[n-1]==6831320)
c29cyc9=c29cyc9+1;
if (v[n-1]==5764064)
c29cyc10=c29cyc10+1;
if (v[n-1]==2308928)
c29cyc11=c29cyc11+1;
if (v[n-1]==81224)
c29cyc12=c29cyc12+1;
if (v[n-1]==30488)
c29cyc13=c29cyc13+1;
if (v[n-1]==147608)
c29cyc14=c29cyc14+1;
printf("cycle for c=29, odd=%d, even=%d, v=%d %d, n=%d %d \n",itero,itere,v[0],v[n-1],n,np);
}
if ((c==25)&&((v[n-1]==136)||(v[n-1]==352)||(v[n-1]==112))) {
if (v[n-1]==136)
c25cyc1=c25cyc1+1;
if (v[n-1]==352)
c25cyc2=c25cyc2+1;
if (v[n-1]==112)
c25cyc3=c25cyc3+1;
printf("cycle for c=25, odd=%d, even=%d, v=%d %d, n=%d %d \n",itero,itere,v[0],v[n-1],n,np);
}
if ((c==23)&&((v[n-1]==1568)||(v[n-1]==440)||(v[n-1]==4976))) {
if (v[n-1]==1538)
c23cyc1=c23cyc1+1;
if (v[n-1]==440)
c23cyc2=c23cyc2+1;
if (v[n-1]==4976)
c23cyc3=c23cyc3+1;
printf("cycle for c=23, odd=%d, even=%d, v=%d %d, n=%d %d \n",itero,itere,v[0],v[n-1],n,np);
}
if ((c==19)&&(v[n-1]==112))
c19cyc1=c19cyc1+1;
if ((c==17)&&((v[n-1]==248)||(v[n-1]==560)||(v[n-1]==200))) {
if (v[n-1]==248)
c17cyc1=c17cyc1+1;
if (v[n-1]==560)
c17cyc2=c17cyc2+1;
if (v[n-1]==200)
c17cyc3=c17cyc3+1;
printf("cycle for c=19, odd=%d, even=%d, v=%d %d, n=%d %d \n",itero,itere,v[0],v[n-1],n,np);
}
if ((c==13)&&((v[n-1]==1816)||(v[n-1]==2008)||(v[n-1]==2296)||(v[n-1]==2728)||(v[n-1]==3376)||(v[n-1]==4192))) {
if (v[n-1]==2008)
c13cyc1=c13cyc1+1;
if (v[n-1]==2296)
c13cyc2=c13cyc2+1;
if (v[n-1]==2728)
c13cyc3=c13cyc3+1;
if (v[n-1]==3376)
c13cyc4=c13cyc4+1;
if (v[n-1]==4192)
c13cyc5=c13cyc5+1;
if (v[n-1]==1816)
c13cyc6=c13cyc6+1;
printf("cycle for c=13, odd=%d, even=%d, v=%d %d, n=%d %d \n",itero,itere,v[0],v[n-1],n,np);
}
if ((c==11)&&(v[n-1]==248)) {
c11cyc1=c11cyc1+1;
printf("cycle for c=11, odd=%d, even=%d, v=%d %d, n=%d %d \n",itero,itere,v[0],v[n-1],n,np);
}
if ((c==7)&&(v[n-1]==40)) {
c7cyc1=c7cyc1+1;
printf("cycle for c=7, odd=%d, even=%d, v=%d %d, n=%d %d \n",itero,itere,v[0],v[n-1],n,np);
}
if ((c==5)&&((v[n-1]==152)||(v[n-1]==6248)||(v[n-1]==5744))) {
if (v[n-1]==152)
c5cyc1=c5cyc1+1;
if (v[n-1]==6248)
c5cyc2=c5cyc2+1;
if (v[n-1]==5744)
c5cyc3=c5cyc3+1;
printf("cycle for c=5, odd=%d, even=%d, v=%d %d, n=%d %d \n",itero,itere,v[0],v[n-1],n,np);
}
if ((c==-1)&&(v[n-1]==272)) {
c1cyc1=c1cyc1+1;
printf("cycle for c=-1, odd=%d, even=%d, v=%d %d, n=%d %d \n",itero,itere,v[0],v[n-1],n,np);
}
if ((c==29)&&((v[n-1]==3128)||(v[n-1]==13064)||(v[n-1]==224)||(v[n-1]==176)||(v[n-1]==1400)||(v[n-1]==1040)))
c29tot=c29tot+1;
if ((c==25)&&((v[n-1]==29512)||(v[n-1]==3352)||(v[n-1]==472)||(v[n-1]==13072)))
c25tot=c25tot+1;
if ((c==23)&&((v[n-1]==872)||(v[n-1]==512)||(v[n-1]==2384)||(v[n-1]==224)||(v[n-1]==440)||(v[n-1]==4976)||(v[n-1]==49520)))
c23tot=c23tot+1;
if ((c==19)&&((v[n-1]==12328)||(v[n-1]==448)||(v[n-1]==832)||(v[n-1]==232)))
c19tot=c19tot+1;
if ((c==17)&&(v[n-1]==798464))
c17tot=c17tot+1;
if ((c==13)&&((v[n-1]==784)||(v[n-1]==136)||(v[n-1]==64)))
c13tot=c13tot+1;
if ((c==11)&&((v[n-1]==248)||(v[n-1]==464)))
c11tot=c11tot+1;
if ((c==5)&&(v[n-1]==152))
c5tot=c5tot+1;
delta=0;
if ((itere!=a)&&(itere!=b)) {
if (itere==(a+1)) {
delta=1;
extra[0]=extra[0]+1;
goto dumbo;
}
if (itere==(a+2)) {
delta=2;
extra[1]=extra[1]+1;
goto dumbo;
}
if (itere==(a+3)) {
delta=3;
extra[2]=extra[2]+1;
goto dumbo;
}
if (itere==(a+4)) {
delta=4;
extra[3]=extra[3]+1;
goto dumbo;
}
if (itere==(a+5)) {
delta=5;
extra[4]=extra[4]+1;
goto dumbo;
}
if (itere==(a+6)) {
delta=6;
extra[5]=extra[5]+1;
goto dumbo;
}
if (itere==(a+7)) {
delta=7;
extra[6]=extra[6]+1;
goto dumbo;
}
printf("error 3: odds=%d, evens=%d \n",itero,itere);
goto zskip;
dumbo:		     if ((c==29)&&((v[n-1]==3128)||(v[n-1]==13064)||(v[n-1]==224)||(v[n-1]==176)||(v[n-1]==1400)||(v[n-1]==1040))) {
printf("exception for c=29, odd=%d, even=%d, delta=%d v=%d %d, n=%d %d \n",itero,itere,delta,v[0],v[n-1],n,np);
c29cnt=c29cnt+1;
}
else {
if ((c==25)&&((v[n-1]==29512)||(v[n-1]==3352)||(v[n-1]==472)||(v[n-1]==13072))) {
printf("exception for c=25, odd=%d, even=%d, delta=%d, v=%d %d, n=%d %d \n",itero,itere,delta,v[0],v[n-1],n,np);
c25cnt=c25cnt+1;
}
else {
if ((c==23)&&((v[n-1]==872)||(v[n-1]==512)||(v[n-1]==2384)||(v[n-1]==224)||(v[n-1]==440)||(v[n-1]==4976)||(v[n-1]==49520))) {
printf("exception for c=23, odd=%d, even=%d, delta=%d, v=%d %d, n=%d %d \n",itero,itere,delta,v[0],v[n-1],n,np);
c23cnt=c23cnt+1;
}
else {
if ((c==19)&&((v[n-1]==12328)||(v[n-1]==448)||(v[n-1]==832)||(v[n-1]==232))) {
printf("exception for c=19, odd=%d, even=%d, delta=%d, v=%d %d, n=%d %d \n",itero,itere,delta,v[0],v[n-1],n,np);
c19cnt=c19cnt+1;
}
else {
if ((c==17)&&((v[n-1]==798464)||(v[n-1]==7040)||(v[n-1]==128)||(v[n-1]==560)||(v[n-1]==248)||(v[n-1]==13088)||(v[n-1]==397784))) {
printf("exception for c=17, odd=%d, even=%d, delta=%d, v=%d %d, n=%d %d \n",itero,itere,delta,v[0],v[n-1],n,np);
c17cnt=c17cnt+1;
}
else {
if ((c==13)&&((v[n-1]==784)||(v[n-1]==136)||(v[n-1]==64))) {
printf("exception for c=13, odd=%d, even=%d, delta=%d, v=%d %d, n=%d %d \n",itero,itere,delta,v[0],v[n-1],n,np);
c13cnt=c13cnt+1;
}
else {
if ((c==11)&&((v[n-1]==248)||(v[n-1]==464))) {
printf("exception for c=11, odd=%d, even=%d, delta=%d, v=%d %d, n=%d %d \n",itero,itere,delta,v[0],v[n-1],n,np);
c11cnt=c11cnt+1;
}
else {
if ((c==5)&&(v[n-1]==152)) {
printf("exception for c=5, odd=%d, even=%d, delta=%d, v=%d %d, n=%d %d\n",itero,itere,delta,v[0],v[n-1],n,np);
c5cnt=c5cnt+1;
}
else {
printf("error: odd=%d, even=%d, v=%d %d, n=%d %d\n",itero,itere,v[0],v[n-1],n,np);
goto zskip;
}
}
}
}
}
}
}
}
}
}
if (itere<b) {
printf("error: odd=%d, even=%d \n",itero,itere);
goto zskip;
}
if (((itere-b)<16)&&(itero<511)) {
ho[16*itero+itere-b]=ho[16*itero+itere-b]+1;
if (itero==row) {
if ((itere!=b)||(nozero==0)) {
table1[index]=itere-b;
index=index+1;
if (index>=100000) {
printf("not enough memory \n");
goto zskip;
}
}
}
}
}
if (count<20) {
printf("l=%d, n=%d \n",itere,itero);
if (row==0) {
fprintf(Outfp,"l=%d, n=%d \n",itere,itero);
fprintf(Outfp," order=%d n=%d, %d %d %d \n",order,n,v[0],v[n-1],np-n);
}
}
for (j=0; j<75; j++) {
if (z[j]==np)
goto bskip;
}
np=np-3;
bskip:	 if (np<2048)
he[np]=he[np]+1;
}
}
dskip:
while (k==(k/2)*2) {
k=k/2; // next sequence value
v[n]=k;
n=n+1; // increment element count
if (n>32767) {
printf("error 2: v array too small %d %d %d %d %d %d\n",v[0],v[1],v[2],v[32765],v[32766],v[32767]);
goto zskip;
}
}
if (c==1) {
if (k!=1)
goto aloop;
}
if (c==-1) {
if ((k!=1)&&(k!=5)&&(k!=7)&&(k!=17)&&(k!=25)&&(k!=37)&&(k!=55)&&(k!=41)&&(k!=61)&&(k!=91))
goto aloop;
if (c1ind==1) {
for (h=0; h<c1ind; h++)
c1[h]=0;
c1ind=0;
goto cskip;
}
if (k==1) {
c1[c1ind]=k;
c1ind=c1ind+1;
}
if (c2ind==2) {
for (h=0; h<c2ind; h++)
c2[h]=0;
c2ind=0;
goto cskip;
}
if ((k==5)||(k==7)) {
c2[c2ind]=k;
c2ind=c2ind+1;
}
if (c3ind==7) {
for (h=0; h<c3ind; h++)
c3[h]=0;
c3ind=0;
goto cskip;
}
if ((k==17)||(k==25)||(k==37)||(k==55)||(k==41)||(k==61)||(k==91)) {
c3[c3ind]=k;
c3ind=c3ind+1;
}
goto aloop;
}
if (c==5) {
if ((k!=1)&&(k!=19)&&(k!=31)&&(k!=49)&&(k!=781)&&(k!=587)&&(k!=883)&&(k!=1327)&&(k!=1993)&&(k!=187)&&(k!=283)&&
(k!=427)&&(k!=643)&&(k!=967)&&(k!=1453)&&(k!=1091)&&(k!=1639)&&(k!=2461)&&(k!=1847)&&(k!=2773)&&(k!=2081)&&(k!=359)&&
(k!=541)&&(k!=407)&&(k!=613)&&(k!=461)&&(k!=347)&&(k!=523)&&(k!=787)&&(k!=1183)&&(k!=1777)&&(k!=667)&&
(k!=1003)&&(k!=1507)&&(k!=2263)&&(k!=3397)&&(k!=2549)&&(k!=1913)&&(k!=23)&&(k!=37)&&(k!=29))
goto aloop;
if (c1ind==1) {
for (h=0; h<c1ind; h++)
c1[h]=0;
c1ind=0;
goto cskip;
}
if (k==1) {
c1[c1ind]=k;
c1ind=c1ind+1;
}
if (c2ind==3) {
for (h=0; h<c2ind; h++)
c2[h]=0;
c2ind=0;
goto cskip;
}
if ((k==19)||(k==31)||(k==49)) {
c2[c2ind]=k;
c2ind=c2ind+1;
}
if (c3ind==17) {
for (h=0; h<c3ind; h++)
c3[h]=0;
c3ind=0;
goto cskip;
}
if ((k==781)||(k==587)||(k==883)||(k==1327)||(k==1993)||(k==187)||(k==283)||
(k==427)||(k==643)||(k==967)||(k==1453)||(k==1091)||(k==1639)||(k==2461)||(k==1847)||(k==2773)||(k==2081)) {
c3[c3ind]=k;
c3ind=c3ind+1;
}
if (c4ind==17) {
for (h=0; h<c4ind; h++)
c4[h]=0;
c4ind=0;
goto cskip;
}
if ((k==359)||(k==541)||(k==407)||(k==613)||(k==461)||(k==347)||(k==523)||(k==787)||(k==1183)||(k==1777)||(k==667)||
(k==1003)||(k==1507)||(k==2263)||(k==3397)||(k==2549)||(k==1913)) {
c4[c4ind]=k;
c4ind=c4ind+1;
}
if (c5ind==3) {
for (h=0; h<c5ind; h++)
c5[h]=0;
c5ind=0;
goto cskip;
}
if ((k==23)||(k==37)||(k==29)) {
c5[c5ind]=k;
c5ind=c5ind+1;
}
goto aloop;
}
if (c==7) {
if ((k!=5)&&(k!=11))
goto aloop;
if (c1ind==2) {
for (h=0; h<c1ind; h++)
c1[h]=0;
c1ind=0;
goto cskip;
}
if ((k==5)||(k==11)) {
c1[c1ind]=k;
c1ind=c1ind+1;
}
goto aloop;
}
if (c==11) {
if ((k!=1)&&(k!=7)&&(k!=31)&&(k!=13)&&(k!=25)&&(k!=43)&&(k!=35)&&(k!=29)&&
(k!=49)&&(k!=79))
goto aloop;
if (c1ind==2) {
for (h=0; h<c1ind; h++)
c1[h]=0;
c1ind=0;
goto cskip;
}
if ((k==1)||(k==7)) {
c1[c1ind]=k;
c1ind=c1ind+1;
}
if (c2ind==8) {
for (h=0; h<c2ind; h++)
c2[h]=0;
c2ind=0;
goto cskip;
}
if ((k==31)||(k==13)||(k==25)||(k==43)||(k==35)||(k==29)||(k==49)||(k==79)) {
c2[c2ind]=k;
c2ind=c2ind+1;
}
goto aloop;
}
if (c==13) {
if ((k!=1)&&(k!=179)&&(k!=275)&&(k!=419)&&(k!=635)&&(k!=959)&&(k!=1445)&&(k!=1087)&&
(k!=1637)&&(k!=1231)&&(k!=1853)&&(k!=1393)&&(k!=131)&&(k!=203)&&(k!=311)&&(k!=473)&&
(k!=211)&&(k!=323)&&(k!=491)&&(k!=743)&&(k!=1121)&&(k!=341)&&(k!=259)&&(k!=395)&&
(k!=599)&&(k!=905)&&(k!=227)&&(k!=347)&&(k!=527)&&(k!=797)&&(k!=601)&&(k!=287)&&
(k!=437)&&(k!=331)&&(k!=503)&&(k!=761)&&(k!=251)&&(k!=383)&&(k!=581)&&(k!=439)&&
(k!=665)&&(k!=283)&&(k!=431)&&(k!=653)&&(k!=493)&&(k!=373)&&(k!=421)&&(k!=319)&&
(k!=485)&&(k!=367)&&(k!=557))
goto aloop;
if (k=1) {
c1[c1ind]=k;
c1ind=c1ind+1;
}
if (c1ind==1) {
for (h=0; h<c1ind; h++)
c1[h]=0;
c1ind=0;
goto cskip;
}
if ((k==179)||(k==275)||(k==419)||(k==635)||(k==959)||(k==1445)||(k==1087)||(k==1637)||
(k==1231)&&(k==1853)||(k==1393)||(k==131)&&(k==203)||(k==311)||(k==473)) {
c2[c2ind]=k;
c2ind=c2ind+1;
}
if (c2ind==15) {
for (h=0; h<c2ind; h++)
c2[h]=0;
c2ind=0;
goto cskip;
}
if ((k==211)||(k==323)||(k==491)||(k==743)||(k==1121)) {
c3[c3ind]=k;
c3ind=c3ind+1;
}
if (c3ind==5) {
for (h=0; h<c3ind; h++)
c3[h]=0;
c3ind=0;
goto cskip;
}
if ((k==341)||(k==259)||(k==395)||(k==599)||(k==905)) {
c4[c4ind]=k;
c4ind=c4ind+1;
}
if (c4ind==5) {
for (h=0; h<c4ind; h++)
c4[h]=0;
c4ind=0;
goto cskip;
}
if ((k==227)||(k==347)||(k==527)||(k==797)||(k==601)) {
c5[c5ind]=k;
c5ind=c5ind+1;
}
if (c5ind==5) {
for (h=0; h<c5ind; h++)
c5[h]=0;
c5ind=0;
goto cskip;
}
if ((k==287)||(k==437)||(k==331)||(k==503)||(k==761)) {
c6[c6ind]=k;
c6ind=c6ind+1;
}
if (c6ind==5) {
for (h=0; h<c6ind; h++)
c6[h]=0;
c6ind=0;
goto cskip;
}
if ((k==251)||(k==383)||(k==581)||(k==439)||(k==665)) {
c7[c7ind]=k;
c7ind=c7ind+1;
}
if (c7ind==5) {
for (h=0; h<c7ind; h++)
c7[h]=0;
c7ind=0;
goto cskip;
}
if ((k==283)||(k==431)||(k==653)||(k==493)||(k==373)) {
c8[c8ind]=k;
c8ind=c8ind+1;
}
if (c8ind==5) {
for (h=0; h<c8ind; h++)
c8[h]=0;
c8ind=0;
goto cskip;
}
if ((k==421)||(k==319)||(k==485)||(k==367)||(k==557)) {
c9[c9ind]=k;
c9ind=c9ind+1;
}
if (c9ind==5) {
for (h=0; h<c9ind; h++)
c9[h]=0;
c9ind=0;
goto cskip;
}
goto aloop;
}
if (c==17) {
if ((k!=1)&&(k!=5)&&(k!=35)&&(k!=61)&&(k!=25)&&(k!=23)&&(k!=43)&&(k!=73)&&
(k!=59)&&(k!=97)&&(k!=77)&&(k!=31)&&(k!=55)&&(k!=91)&&(k!=145)&&(k!=113)&&
(k!=89)&&(k!=71)&&(k!=115)&&(k!=181))
goto aloop;
if ((k==1)||(k==5)) {
c1[c1ind]=k;
c1ind=c1ind+1;
}
if (c1ind==2) {
for (h=0; h<c1ind; h++)
c1[h]=0;
c1ind=0;
goto cskip;
}
if ((k==35)||(k==61)||(k==25)||(k==23)||(k==43)||(k==73)||(k==59)||(k==97)||
(k==77)||(k==31)||(k==55)||(k==91)||(k==145)||(k==113)||(k==89)||(k==71)||
(k==115)||(k==181)) {
c2[c2ind]=k;
c2ind=c2ind+1;
}
if (c2ind==18) {
for (h=0; h<c2ind; h++)
c2[h]=0;
c2ind=0;
goto cskip;
}
goto aloop;
}
if (c==19) {
if ((k!=7)&&(k!=5)&&(k!=17)&&(k!=35)&&(k!=31))
goto aloop;
if ((k==7)||(k==5)||(k==17)||(k==35)||(k==31)) {
c1[c1ind]=k;
c1ind=c1ind+1;
}
if (c1ind==5) {
for (h=0; h<c1ind; h++)
c1[h]=0;
c1ind=0;
goto cskip;
}
goto aloop;
}
if (c==23) {
if ((k!=311)&&(k!=239)&&(k!=185)&&(k!=289)&&(k!=445)&&(k!=679)&&(k!=515)&&(k!=49)&&
(k!=85)&&(k!=139)&&(k!=55)&&(k!=47)&&(k!=41)&&(k!=73)&&(k!=121)&&(k!=193)&&
(k!=301)&&(k!=463)&&(k!=353)&&(k!=541)&&(k!=823)&&(k!=623)&&(k!=473)&&(k!=721)&&
(k!=1093)&&(k!=1651))
goto aloop;
if ((k==311)||(k==239)||(k==185)||(k==289)||(k==445)||(k==679)||(k==515)||(k==49)||
(k==85)||(k==139)||(k==55)||(k==47)||(k==41)||(k==73)||(k==121)||(k==193)||(k==301)||
(k==463)||(k==353)||(k==541)||(k==823)||(k==623)||(k==473)||(k==721)||(k==1093)||(k==1651)) {
c1[c1ind]=k;
c1ind=c1ind+1;
}
if (c1ind==26) {
for (h=0; h<c1ind; h++)
c1[h]=0;
c1ind=0;
goto cskip;
}
goto aloop;
}
if (c==25) {
if ((k!=17)&&(c!=19)&&(c!=41)&&(c!=37)&&(c!=11)&&(c!=29)&&(c!=7)&&(c!=23)&&(c!=47)&&
(k!=83)&&(k!=137)&&(k!=109))
goto aloop;
if ((k==17)||(k==19)||(k==41)||(k==37)) {
c1[c1ind]=k;
c1ind=c1ind+1;
}
if (c1ind==4) {
for (h=0; h<c1ind; h++)
c1[h]=0;
c1ind=0;
goto cskip;
}
if ((k==11)||(k==29)||(k==7)||(k==23)||(k==47)||(k==83)||(k==137)||(k==109)) {
c2[c2ind]=k;
c2ind=c2ind+1;
}
if (c2ind==8) {
for (h=0; h<c2ind; h++)
c2[h]=0;
c2ind=0;
goto cskip;
}
goto aloop;
}
if (c==29) {
if ((k!=49)&&(k!=11)&&(k!=31)&&(k!=61)&&(k!=53)&&(k!=47)&&(k!=85)&&(k!=71)&&(k!=121)&&
(k!=98569)&&(k!=36967)&&(k!=55465)&&(k!=20803)&&(k!=31219)&&(k!=46843)&&(k!=70279)&&
(k!=105433)&&(k!=39541)&&(k!=29663)&&(k!=44509)&&(k!=33389)&&(k!=25049)&&(k!=9397)&&
(k!=7055)&&(k!=10597)&&(k!=7955)&&(k!=11947)&&(k!=17935)&&(k!=26917)&&(k!=20195)&&
(k!=30307)&&(k!=45475)&&(k!=68227)&&(k!=102355)&&(k!=153547)&&(k!=230335)&&
(k!=345517)&&(k!=259145)&&(k!=97183)&&(k!=109349)&&(k!=82019)&&(k!=123043)&&
(k!=184579)&&(k!=276883)&&(k!=415339)&&(k!=623023)&&(k!=934549)&&(k!=700919)&&(k!=1051393)&&
(k!=853915)&&(k!=1280887)&&(k!=1921345)&&(k!=180127)&&(k!=270205)&&(k!=202661)&&
(k!=152003)&&(k!=228019)&&(k!=342043)&&(k!=513079)&&(k!=769633)&&(k!=36077)&&
(k!=27065)&&(k!=10153)&&(k!=3811)&&(k!=5731)&&(k!=8611)&&(k!=12931)&&(k!=19411)&&
(k!=29131)&&(k!=43711)&&(k!=65581)&&(k!=49193)&&(k!=18451)&&(k!=27691)&&(k!=41551)&&
(k!=62341)&&(k!=46763)&&(k!=70159)&&(k!=105253)&&(k!=78947)&&(k!=118435)&&(k!=177667)&&
(k!=266515)&&(k!=399787)&&(k!=599695)&&(k!=899557)&&(k!=674675)&&(k!=1012027)&&
(k!=1518055)&&(k!=2277097))
goto aloop;
if ((k==49)||(k==11)||(k==31)||(k==61)||(k==53)||(k==47)||(k==85)||(k==71)||(k==121)) {
c1[c1ind]=k;
c1ind=c1ind+1;
}
if (c1ind==9) {
for (h=0; h<c1ind; h++)
c1[h]=0;
c1ind=0;
goto cskip;
}
if ((k==98569)||(k==36967)||(k==55465)||(k==20803)||(k==31219)||(k==46843)||(k==70279)||
(k==105433)||(k==39541)||(k==29663)||(k==44509)||(k==33389)||(k==25049)||(k==9397)||
(k==7055)||(k==10597)||(k==7955)||(k==11947)||(k==17935)||(k==26917)||(k==20195)||
(k==30307)||(k==45475)||(k==68227)||(k==102355)||(k==153547)||(k==230335)||
(k==345517)||(k==259145)||(k==97183)||(k==109349)||(k==82019)||(k==123043)||
(k==184579)||(k==276883)||(k==415339)||(k==623023)||(k==934549)||(k==700919)||(k==1051393)) {
c2[c2ind]=k;
c2ind=c2ind+1;
}
if (c2ind==40) {
for (h=0; h<c2ind; h++)
c2[h]=0;
c2ind=0;
goto cskip;
}
if ((k==853915)||(k==1280887)||(k==1921345)||(k==180127)||(k==270205)||(k==202661)||
(k==152003)||(k==228019)||(k==342043)||(k==513079)||(k==769633)||(k==36077)||
(k==27065)||(k==10153)||(k==3811)||(k==5731)||(k==8611)||(k==12931)||(k==19411)||
(k==29131)||(k==43711)||(k==65581)||(k==49193)||(k==18451)||(k==27691)||(k==41551)||
(k==62341)||(k==46763)||(k==70159)||(k==105253)||(k==78947)||(k==118435)||(k==177667)||
(k==266515)||(k==399787)||(k==599695)||(k==899557)||(k==674675)||(k==1012027)||
(k==1518055)||(k==2277097)) {
c3[c3ind]=k;
c3ind=c3ind+1;
}
if (c3ind==41) {
for (h=0; h<c3ind; h++)
c3[h]=0;
c3ind=0;
goto cskip;
}
goto aloop;
}
cskip:
k=0;
c1ind=0;
c2ind=0;
c3ind=0;
c4ind=0;
c5ind=0;
c6ind=0;
c7ind=0;
c8ind=0;
c9ind=0;
}
//
// check for valid lengths//
for (i=0; i<178; i++) {
if (he[y[i]]!=0)
printf("exception for length, c=%d, l=%d, count=%d \n",c,y[i]+3,he[y[i]]);
}
//
// HISTOGRAM OF LENGTHS
//
printf("\n");
if (row==0) {
fprintf(Outfp,"\n");
fprintf(Outfp,"HISTOGRAM \n");
printf("HISTOGRAM OF LENGTHS \n");
for (h=0; h<64; h++) {
fprintf(Outfp," %d %d %d %d %d %d %d %d \n",he[8*h],he[8*h+1],he[8*h+2],
he[8*h+3],he[8*h+4],he[8*h+5],he[8*h+6],he[8*h+7]);
printf(" %d %d %d %d %d %d %d %d \n",he[8*h],he[8*h+1],he[8*h+2],
he[8*h+3],he[8*h+4],he[8*h+5],he[8*h+6],he[8*h+7]);
}
}
//
// HISTOGRAM OF LENGTHS
//
fprintf(Outfp,"\n");
printf("\n");
if (row==0) {
fprintf(Outfp,"HISTOGRAM \n");
printf("HISTOGRAM OF NUMBER OF EVEN ELEMENTS (PER NUMBER OF ODD ELEMENTS)\n");
for (h=0; h<64; h++) {
fprintf(Outfp," %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n",ho[16*h],
ho[16*h+1],ho[16*h+2],ho[16*h+3],ho[16*h+4],ho[16*h+5],ho[16*h+6],
ho[16*h+7],ho[16*h+8],ho[16*h+9],ho[16*h+10],ho[16*h+11],ho[16*h+12],
ho[16*h+13],ho[16*h+14],ho[16*h+15]);
printf(" %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n",ho[16*h],
ho[16*h+1],ho[16*h+2],ho[16*h+3],ho[16*h+4],ho[16*h+5],ho[16*h+6],
ho[16*h+7],ho[16*h+8],ho[16*h+9],ho[16*h+10],ho[16*h+11],ho[16*h+12],
ho[16*h+13],ho[16*h+14],ho[16*h+15]);
}
if (c==-1)
printf("cycle count=%d \n",c1cyc1);
if (c==5) {
printf("c5 exception count=%d, total=%d \n",c5cnt,c5tot);
printf("cycle count=%d %d %d\n",c5cyc1,c5cyc2,c5cyc3);
}
if (c==7) {
printf("c7 exception count=%d, total=%d \n",c7cnt,c7tot);
printf("cycle count=%d \n",c7cyc1);
}
if (c==11) {
printf("c11 exception count=%d, total=%d \n",c11cnt,c11tot);
printf("cycle count=%d \n",c11cyc1);
}
if (c==13) {
printf("c13 exception count=%d, total=%d \n",c13cnt,c13tot);
printf("cycle counts=%d %d %d %d %d %d\n",c13cyc1,c13cyc2,c13cyc3,c13cyc4,c13cyc5,c13cyc6);
}
if (c==17) {
printf("c17 exception count=%d, total=%d \n",c17cnt,c17tot);
printf("cycle counts=%d %d %d \n",c17cyc1,c17cyc2,c17cyc3);
}
if (c==19) {
printf("c19 exception count=%d, total=%d \n",c19cnt,c19tot);
printf("cycle count=%d \n",c19cyc1);
}
if (c==23) {
printf("c23 exception count=%d, total=%d \n",c23cnt,c23tot);
printf("cycle counts=%d %d %d \n",c23cyc1,c23cyc2,c23cyc3);
}
if (c==25) {
printf("c25 exception count=%d, total=%d \n",c25cnt,c25tot);
printf("cycle counts=%d %d %d \n",c25cyc1,c25cyc2,c25cyc3);
}
if (c==29) {
printf("c29 exception count=%d, total=%d \n",c29cnt,c29tot);
printf("cycle counts=%d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",c29cyc1,c29cyc2,c29cyc3,c29cyc4,c29cyc5,c29cyc6,c29cyc7,c29cyc8,c29cyc9,c29cyc10,c29cyc11,c29cyc12,c29cyc13,c29cyc14);
}
printf("extra=%d %d %d %d %d %d %d\n",extra[0],extra[1],extra[2],extra[3],extra[4],extra[5],extra[6]);
}
if (row!=0) {
printf("index=%d \n",index);
for (h=0; h<index; h++)
fprintf(Outfp," %d,\n",table1[h]);
}
zskip:
fclose(Outfp);
return(0);
}
```