/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* Conway.c
* Copyright (C) drdev 2012
*
* Conway is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Conway is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*/
/* Calculates Conway sequences (see Richard K. Guy, Tanya Khovanova and
Julian Salazar, 'Conway's subprime Fibonacci sequences," arXiv, July 21, 2012,
http://arxiv.org/abs/1207.5099) */
/*test vector for n0 =0, n1=1
0 1 1 2 3 5 4 3 7 5 6 11 17 14 31 15 23 19 21 20 41 61 51 56 107 163 135 149 142
97 239 168 37 41 39 40 79 17 48 13 61 37 49 43 46 89 45 67 56 41 97 69 83 76
53 43 48 13 61 37 . . .*/
#include
#include
#include
/* Prototypes */
void exit(int status);
int sum_digits(int n);
int factor(int n);
char *strcpy(char *dest, const char *src);
/* end of prototypes */
int i, n0, n1, n2;
FILE *outdata;
int factor(int n)
// returns smallest prime factor of a composite number n; will return 1 if the number is a prime number
{
int t; // t is the factor that's tested; start small, work bigger
/* while the test factor t is lower than the number to be factored */
for (t=2;t<=n;t++)
if((n % t) == 0)
{
if (t