471,831 Members | 1,262 Online

# Conway Sequence 6
I have written a program to calculate the Conway Sequence (eg 3, 13, 1113, 3113, .....) which is:

#include <math.h>
#include <stdio.h>

int i, f;
int con, m, n, p, q, rept, count, r;

main()
{
for(n=0;n<100000;n++)
{
i[n] = 0;
f[n] = 0;
}
printf("Enter a number between 1 and 9: ");
scanf("%d",&i);
printf("How many times do you want to run the sequence? ");
scanf("%d",&rept);
printf("%d\n",i);
count = 0;
do{

m=0,p=0;

while(i[m] > 0)
{
if(i[m] == i[m+1])
{
r = 2;
m = m + 1;

while(i[m] == i[m+1])
{
r = r + 1;
m = m + 1;
}

f[p] = r;
f[p+1] = i[m-1];
m = m + 1;
p = p + 2;
}
else
{
f[p] = 1;
f[p+1] = i[m];

m = m+1;
p = p+2;
}

}
q = 0;
while(f[q]>0)
{
printf("%d",f[q]);
q=q+1;
}
printf("\n");

for(con=0;con<100000;con++)
{
i[con] = f[con];
}

count = count + 1;
}
while(count<rept);

}

It works fine, but i was wondering if i can make it to start with a number greater than 9, so a two or more digit number?
Oct 22 '06 #1
0 1064 10 posts views Thread by Anthony Best | last post: by 5 posts views Thread by Eric E | last post: by 3 posts views Thread by kevin | last post: by 8 posts views Thread by regis | last post: by 4 posts views Thread by Putty | last post: by 14 posts views Thread by pat270881 | last post: by 6 posts views Thread by Defcon2030 | last post: by 1 post views Thread by davydany | last post: by 5 posts views Thread by Anan18 | last post: by reply views Thread by NeoPa | last post: by reply views Thread by antdb | last post: by reply views Thread by YellowAndGreen | last post: by reply views Thread by AndresCidInst | last post: by 1 post views Thread by guiromero | last post: by 7 posts views Thread by Petrol | last post: by reply views Thread by isladogs | last post: by reply views Thread by beacampos | last post: by reply views Thread by RonaldHiggins22 | last post: by