All pastes #425780 Raw Edit

Stuff

public c v1 · immutable
·published 2007-04-05 18:23 UTC
rendered paste body
#include<stdio.h>#include<stdlib.h>typedef struct number_node {        char digit;        struct number_node *next;} number;int main() {        number *head;        int len;        int tobase = 7;        int i;        head = (number*)malloc(sizeof(number));        head->digit = 1;        head->next = NULL;        for(i=1;i<10000;i++) {                int remainder = 0;                int n = 0;                char three = 0;                int row = 0;                number *current = head;                do {                        int temp = current->digit * 2 + remainder;                        current->digit = temp % tobase;                        remainder = (temp - current->digit) / tobase;                        if(current->digit == 0) row++;                        else row=0;                        if(row == 3) three = 1;                        n++;                        if(current->next) current = current->next;                        else if(remainder) {                                current->next = malloc(sizeof(number));                                current = current->next;                                current->digit = 0;                                current->next = NULL;                                len++;                        }                        else current = NULL;                } while(current);                if(three)                        printf("%d\n",i);        }        return 0;}