468,484 Members | 2,076 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

Conway Sequence

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[100000], f[100000];
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[0]);
printf("How many times do you want to run the sequence? ");
scanf("%d",&rept);
printf("%d\n",i[0]);
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?
Please help, Thanks
Oct 22 '06 #1
0 1000

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Anthony Best | last post: by
5 posts views Thread by Eric E | 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
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.