home bbs files messages ]

Just a sample of the Echomail archive

COMPLANC:

<< oldest | < older | list | newer > | newest >> ]

 Message 243,102 of 243,119 
 Jan van den Broek to All 
 Re: Collatz Conjecture proved. 
 31 Jan 26 14:11:20 
 
From: fortytwo@xs4all.nl

I'm not intendig to proof anything, but I wrote this some time ago when being
bored.

#include 
#include 
#include 
#include 
#include 

#define N 1024

int check(char *s)
{
  int result=1;
  while (*s)
  {
    if (!isdigit(*s++))
    {
      result=0;
    }
  }
  return(result);
}

char *insert(char *s,char c,int *l)
{
  int i;
  assert (*l<(N-1));

  for (i=*l; i; --i)
  {
    s[i]=s[i-1];
  }
  s[0]=c;
  ++(*l);
  s[*l]='\0';
  return(s);
}

char *even(char *s,int *l)
{
  int c,carry,i;
  char *copy;

  copy=malloc(*l+1);
  assert(copy!=NULL);
  copy[*l]='\0';
  carry=0;
  for (i=0; i<*l; ++i)
  {
    c=s[i]-'0'+carry;
    carry=0;
    if (c&1)
    {
      carry=10;
      c-=1;
    }
    c=c/2;
    copy[i]=c+'0';
  }
  i=0;
  while (copy[i]=='0')
  {
    ++i;
  }
  (*l)-=i;
  strcpy(s,copy+i);
  free(copy);
  return(s);
}

char *odd(char *s,int *l)
{
  int c,carry,i;
  char *copy;

  copy=malloc(*l+2);
  assert(copy!=NULL);
  carry=0;
  copy[*l]='\0';
  for (i=*l; i; --i)
  {
    c=3*(s[i-1]-'0')+carry;
    if (i==*l)
    {
      ++c;
    }
    copy[i-1]=(c%10)+'0';
    carry=(c-(c%10))/10;
  }
  while(carry)
  {
    c=carry%10;
    insert(copy,c+'0',l);
    carry=(c-(c%10))/10;
  }
  strcpy(s,copy);
  free(copy);
  return(s);
}

int main(int argc,char *argv[])
{
  int i,l;
  char data[N];

  for (i=1; i

<< oldest | < older | list | newer > | newest >> ]


(c) 1994,  bbs@darkrealms.ca