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