WeixiangYan/CodeTransOcean huggingface dataset:
Task: 99 bottles of beer


C++: #include <iostream>
using std::cout;

int main() 
{
  for(int bottles(99); bottles > 0; bottles -= 1){
    cout << bottles << " bottles of beer on the wall\n"
         << bottles << " bottles of beer\n"
         << "Take one down, pass it around\n"
         << bottles - 1 << " bottles of beer on the wall\n\n";
  }
}







VB: Dim bottles As Integer = 99
While bottles > 0
   Print(bottles.ToText + " bottles of beer on the wall,")
   Print(bottles.ToText + " bottles of beer.")
   Print("Take one down, pass it around.")
   bottles = bottles - 1
   Print(bottles.ToText + " bottles of beer on the wall.")
   Print ""
Wend
Task: 99 bottles of beer




Go: package main

import "fmt"

func main() {
	bottles := func(i int) string {
		switch i {
		case 0:
			return "No more bottles"
		case 1:
			return "1 bottle"
		default:
			return fmt.Sprintf("%d bottles", i)
		}
	}

	for i := 99; i > 0; i-- {
		fmt.Printf("%s of beer on the wall\n", bottles(i))
		fmt.Printf("%s of beer\n", bottles(i))
		fmt.Printf("Take one down, pass it around\n")
		fmt.Printf("%s of beer on the wall\n", bottles(i-1))
	}
}


Java: module Bottles
    {
    @Inject Console console;
    void run()
        {
        function String(Int) num     = i -> i==0 ? "No" : i.toString();
        function String(Int) bottles = i -> i==1 ? "bottle" : "bottles";

        for (Int remain : 99..1)
            {
            console.print($|{num(remain)} {bottles(remain)} of beer on the wall
                           |{num(remain)} {bottles(remain)} of beer
                           |Take one down, pass it around
                           |{num(remain-1)} {bottles(remain-1)} of beer on the wall
                           |
                         );
            }
        }
    }
Task: 99 bottles of beer





Java: module Bottles
    {
    @Inject Console console;
    void run()
        {
        function String(Int) num     = i -> i==0 ? "No" : i.toString();
        function String(Int) bottles = i -> i==1 ? "bottle" : "bottles";

        for (Int remain : 99..1)
            {
            console.print($|{num(remain)} {bottles(remain)} of beer on the wall
                           |{num(remain)} {bottles(remain)} of beer
                           |Take one down, pass it around
                           |{num(remain-1)} {bottles(remain-1)} of beer on the wall
                           |
                         );
            }
        }
    }



Python: fun bottles(n): match __args__:
    (0) => "No more bottles"
    (1) => "1 bottle"
    (_) => "$n bottles"

for n in 99..-1..1:
    print @format
Task: 99 bottles of beer





Java: module Bottles
    {
    @Inject Console console;
    void run()
        {
        function String(Int) num     = i -> i==0 ? "No" : i.toString();
        function String(Int) bottles = i -> i==1 ? "bottle" : "bottles";

        for (Int remain : 99..1)
            {
            console.print($|{num(remain)} {bottles(remain)} of beer on the wall
                           |{num(remain)} {bottles(remain)} of beer
                           |Take one down, pass it around
                           |{num(remain-1)} {bottles(remain-1)} of beer on the wall
                           |
                         );
            }
        }
    }




VB: Dim bottles As Integer = 99
While bottles > 0
   Print(bottles.ToText + " bottles of beer on the wall,")
   Print(bottles.ToText + " bottles of beer.")
   Print("Take one down, pass it around.")
   bottles = bottles - 1
   Print(bottles.ToText + " bottles of beer on the wall.")
   Print ""
Wend
Task: 99 bottles of beer




Go: package main

import "fmt"

func main() {
	bottles := func(i int) string {
		switch i {
		case 0:
			return "No more bottles"
		case 1:
			return "1 bottle"
		default:
			return fmt.Sprintf("%d bottles", i)
		}
	}

	for i := 99; i > 0; i-- {
		fmt.Printf("%s of beer on the wall\n", bottles(i))
		fmt.Printf("%s of beer\n", bottles(i))
		fmt.Printf("Take one down, pass it around\n")
		fmt.Printf("%s of beer on the wall\n", bottles(i-1))
	}
}





VB: Dim bottles As Integer = 99
While bottles > 0
   Print(bottles.ToText + " bottles of beer on the wall,")
   Print(bottles.ToText + " bottles of beer.")
   Print("Take one down, pass it around.")
   bottles = bottles - 1
   Print(bottles.ToText + " bottles of beer on the wall.")
   Print ""
Wend
Task: 99 bottles of beer







Python: fun bottles(n): match __args__:
    (0) => "No more bottles"
    (1) => "1 bottle"
    (_) => "$n bottles"

for n in 99..-1..1:
    print @format


VB: Dim bottles As Integer = 99
While bottles > 0
   Print(bottles.ToText + " bottles of beer on the wall,")
   Print(bottles.ToText + " bottles of beer.")
   Print("Take one down, pass it around.")
   bottles = bottles - 1
   Print(bottles.ToText + " bottles of beer on the wall.")
   Print ""
Wend
Task: 99 bottles of beer




Go: package main

import "fmt"

func main() {
	bottles := func(i int) string {
		switch i {
		case 0:
			return "No more bottles"
		case 1:
			return "1 bottle"
		default:
			return fmt.Sprintf("%d bottles", i)
		}
	}

	for i := 99; i > 0; i-- {
		fmt.Printf("%s of beer on the wall\n", bottles(i))
		fmt.Printf("%s of beer\n", bottles(i))
		fmt.Printf("Take one down, pass it around\n")
		fmt.Printf("%s of beer on the wall\n", bottles(i-1))
	}
}




Python: fun bottles(n): match __args__:
    (0) => "No more bottles"
    (1) => "1 bottle"
    (_) => "$n bottles"

for n in 99..-1..1:
    print @format
Task: Numbers in base-16 representation that cannot be written with decimal digits

C: #include<stdio.h>

int main()
{
 int q,r;

 for(q=0;q<16;q++){
   for(r=10;r<16;r++){
     printf("%5d",16*q+r);
   }
 }

return 0;
}



C#: #include<iostream>
using namespace std;

int main()
{
 int q,r;

 for(q=0;q<16;q++){
   for(r=10;r<16;r++){
     std::cout<<16*q+r<<" ";
   }
 }

return 0;
}
Task: Numbers in base-16 representation that cannot be written with decimal digits

C: #include<stdio.h>

int main()
{
 int q,r;

 for(q=0;q<16;q++){
   for(r=10;r<16;r++){
     printf("%5d",16*q+r);
   }
 }

return 0;
}







Python: [print(16*q + r,end=' ') for q in range(0,16) for r in range(10,16)]
Task: Numbers in base-16 representation that cannot be written with decimal digits


C++: #include<iostream>
using namespace std;

int main()
{
 int q,r;

 for(q=0;q<16;q++){
   for(r=10;r<16;r++){
     std::cout<<16*q+r<<" ";
   }
 }

return 0;
}






Python: [print(16*q + r,end=' ') for q in range(0,16) for r in range(10,16)]
Task: Numbers in base-16 representation that cannot be written with decimal digits

C: #include<stdio.h>

int main()
{
 int q,r;

 for(q=0;q<16;q++){
   for(r=10;r<16;r++){
     printf("%5d",16*q+r);
   }
 }

return 0;
}


C++: #include<iostream>
using namespace std;

int main()
{
 int q,r;

 for(q=0;q<16;q++){
   for(r=10;r<16;r++){
     std::cout<<16*q+r<<" ";
   }
 }

return 0;
}
Task: Numbers in base-16 representation that cannot be written with decimal digits

C: #include<stdio.h>

int main()
{
 int q,r;

 for(q=0;q<16;q++){
   for(r=10;r<16;r++){
     printf("%5d",16*q+r);
   }
 }

return 0;
}




Go: package main
 
import (
    "fmt"
    "strconv"
    "strings"
)
 
func main() {
    const decimal = "0123456789"
    c := 0
    for i := int64(1); i < 500; i++ {
        hex := strconv.FormatInt(i, 16)
        if !strings.ContainsAny(decimal, hex) {
            fmt.Printf("%3d ", i)
            c++
            if c%14 == 0 {
                fmt.Println()
            }
        }
    }
    fmt.Printf("\n%d such numbers found.\n", c)
}
Task: Numbers in base-16 representation that cannot be written with decimal digits


C++: #include<iostream>
using namespace std;

int main()
{
 int q,r;

 for(q=0;q<16;q++){
   for(r=10;r<16;r++){
     std::cout<<16*q+r<<" ";
   }
 }

return 0;
}



Go: package main
 
import (
    "fmt"
    "strconv"
    "strings"
)
 
func main() {
    const decimal = "0123456789"
    c := 0
    for i := int64(1); i < 500; i++ {
        hex := strconv.FormatInt(i, 16)
        if !strings.ContainsAny(decimal, hex) {
            fmt.Printf("%3d ", i)
            c++
            if c%14 == 0 {
                fmt.Println()
            }
        }
    }
    fmt.Printf("\n%d such numbers found.\n", c)
}
Task: Numbers in base-16 representation that cannot be written with decimal digits




Go: package main
 
import (
    "fmt"
    "strconv"
    "strings"
)
 
func main() {
    const decimal = "0123456789"
    c := 0
    for i := int64(1); i < 500; i++ {
        hex := strconv.FormatInt(i, 16)
        if !strings.ContainsAny(decimal, hex) {
            fmt.Printf("%3d ", i)
            c++
            if c%14 == 0 {
                fmt.Println()
            }
        }
    }
    fmt.Printf("\n%d such numbers found.\n", c)
}




Python: [print(16*q + r,end=' ') for q in range(0,16) for r in range(10,16)]
Task: Set puzzle

C: #include <stdio.h>
#include <stdlib.h>

char *names[4][3] = {
	{ "red", "green", "purple" },
	{ "oval", "squiggle", "diamond" },
	{ "one", "two", "three" },
	{ "solid", "open", "striped" }
};

int set[81][81];

void init_sets(void)
{
	int i, j, t, a, b;
	for (i = 0; i < 81; i++) {
		for (j = 0; j < 81; j++) {
			for (t = 27; t; t /= 3) {
				a = (i / t) % 3;
				b = (j / t) % 3;
				set[i][j] += t * (a == b ? a : 3 - a - b);
			}
		}
	}
}

void deal(int *out, int n)
{
	int i, j, t, c[81];
	for (i = 0; i < 81; i++) c[i] = i;
	for (i = 0; i < n; i++) {
		j = i + (rand() % (81 - i));
		t = c[i], c[i] = out[i] = c[j], c[j] = t;
	}
}

int get_sets(int *cards, int n, int sets[][3])
{
	int i, j, k, s = 0;
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			for (k = j + 1; k < n; k++) {
				if (set[cards[i]][cards[j]] == cards[k])
					sets[s][0] = i,
					sets[s][1] = j,
					sets[s][2] = k,
					s++;
			}
		}
	}

	return s;
}

void show_card(int c)
{
	int i, t;
	for (i = 0, t = 27; t; i++, t /= 3)
		printf("%9s", names[i][(c/t)%3]);
	putchar('\n');
}

void deal_sets(int ncard, int nset)
{
	int c[81];
	int csets[81][3]; 
	int i, j, s;

	do deal(c, ncard); while ((s = get_sets(c, ncard, csets)) != nset);

	printf("dealt %d cards\n", ncard);
	for (i = 0; i < ncard; i++) {
		printf("%2d:", i);
		show_card(c[i]);
	}
	printf("\nsets:\n");

	for (i = 0; i < s; i++) {
		for (j = 0; j < 3; j++) {
			printf("%2d:", csets[i][j]);
			show_card(c[csets[i][j]]);
		}
		putchar('\n');
	}
}

int main(void)
{
	init_sets();
	deal_sets(9, 4);

	while (1) deal_sets(12, 6);

	return 0;
}







Python: 
    
from itertools import product, combinations
from random import sample
 

features = [ 'green purple red'.split(),
             'one two three'.split(),
             'oval diamond squiggle'.split(),
             'open striped solid'.split() ]
             
deck = list(product(list(range(3)), repeat=4))

dealt = 9
 

def printcard(card):
    print(' '.join('%8s' % f[i] for f,i in zip(features, card)))
 
def getdeal(dealt=dealt):
    deal = sample(deck, dealt)
    return deal
 
def getsets(deal):
    good_feature_count = set([1, 3])
    sets = [ comb for comb in combinations(deal, 3)
             if all( [(len(set(feature)) in good_feature_count)
                     for feature in zip(*comb)]
                   ) ]
    return sets
 
def printit(deal, sets):
    print('Dealt %i cards:' % len(deal))
    for card in deal: printcard(card)
    print('\nFound %i sets:' % len(sets))
    for s in sets:
        for card in s: printcard(card)
        print('')
 
if __name__ == '__main__':
    while True:
        deal = getdeal()
        sets = getsets(deal)
        if len(sets) == dealt / 2:
           break
    printit(deal, sets)
Task: Set puzzle




Go: package main

import (
    "fmt"
    "math/rand"
    "time"
)

const (
    number = [3]string{"1", "2", "3"}
    color  = [3]string{"red", "green", "purple"}
    shade  = [3]string{"solid", "open", "striped"}
    shape  = [3]string{"oval", "squiggle", "diamond"}
)

type card int

func (c card) String() string {
    return fmt.Sprintf("%s %s %s %s",
        number[c/27],
        color[c/9%3],
        shade[c/3%3],
        shape[c%3])
}

func main() {
    rand.Seed(time.Now().Unix())
    game("Basic", 9, 4)
    game("Advanced", 12, 6)
}

func game(level string, cards, sets int) {
    
    d := make([]card, 81)
    for i := range d {
        d[i] = card(i)
    }
    var found [][3]card
    for len(found) != sets {
        found = found[:0]
        
        for i := 0; i < cards; i++ {
            j := rand.Intn(81 - i)
            d[i], d[j] = d[j], d[i]
        }
        
        for i := 2; i < cards; i++ {
            c1 := d[i]
            for j := 1; j < i; j++ {
                c2 := d[j]
            l3:
                for _, c3 := range d[:j] {
                    for f := card(1); f < 81; f *= 3 {
                        if (c1/f%3 + c2/f%3 + c3/f%3) % 3 != 0 {
                            continue l3 
                        }
                    }
                    
                    found = append(found, [3]card{c1, c2, c3})
                }
            }
        }
    }
    
    fmt.Printf("%s game.  %d cards, %d sets.\n", level, cards, sets)
    fmt.Println("Cards:")
    for _, c := range d[:cards] {
        fmt.Println("  ", c)
    }
    fmt.Println("Sets:")
    for _, s := range found {
        fmt.Printf("  %s\n  %s\n  %s\n",s[0],s[1],s[2])
    }
}




Python: 
    
from itertools import product, combinations
from random import sample
 

features = [ 'green purple red'.split(),
             'one two three'.split(),
             'oval diamond squiggle'.split(),
             'open striped solid'.split() ]
             
deck = list(product(list(range(3)), repeat=4))

dealt = 9
 

def printcard(card):
    print(' '.join('%8s' % f[i] for f,i in zip(features, card)))
 
def getdeal(dealt=dealt):
    deal = sample(deck, dealt)
    return deal
 
def getsets(deal):
    good_feature_count = set([1, 3])
    sets = [ comb for comb in combinations(deal, 3)
             if all( [(len(set(feature)) in good_feature_count)
                     for feature in zip(*comb)]
                   ) ]
    return sets
 
def printit(deal, sets):
    print('Dealt %i cards:' % len(deal))
    for card in deal: printcard(card)
    print('\nFound %i sets:' % len(sets))
    for s in sets:
        for card in s: printcard(card)
        print('')
 
if __name__ == '__main__':
    while True:
        deal = getdeal()
        sets = getsets(deal)
        if len(sets) == dealt / 2:
           break
    printit(deal, sets)
Task: Left factorials

C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmp.h>

void mpz_left_fac_ui(mpz_t rop, unsigned long op)
{
    mpz_t t1;
    mpz_init_set_ui(t1, 1);
    mpz_set_ui(rop, 0);

    size_t i;
    for (i = 1; i <= op; ++i) {
        mpz_add(rop, rop, t1);
        mpz_mul_ui(t1, t1, i);
    }

    mpz_clear(t1);
}

size_t mpz_digitcount(mpz_t op)
{
    
    char *t    = mpz_get_str(NULL, 10, op);
    size_t ret = strlen(t);
    free(t);
    return ret;
}

int main(void)
{
    mpz_t t;
    mpz_init(t);
    size_t i;

    for (i = 0; i <= 110; ++i) {
        if (i <= 10 || i % 10 == 0) {
            mpz_left_fac_ui(t, i);
            gmp_printf("!%u = %Zd\n", i, t);
        }
    }

    for (i = 1000; i <= 10000; i += 1000) {
        mpz_left_fac_ui(t, i);
        printf("!%u has %u digits\n", i, mpz_digitcount(t));
    }

    mpz_clear(t);
    return 0;
}



C#: using System;
using System.Numerics;

namespace LeftFactorial
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i <= 10; i++)
            {
                Console.WriteLine(string.Format("!{0} = {1}", i, LeftFactorial(i)));
            }

            for (int j = 20; j <= 110; j += 10)
            {
                Console.WriteLine(string.Format("!{0} = {1}", j, LeftFactorial(j)));
            }

            for (int k = 1000; k <= 10000; k += 1000)
            {
                Console.WriteLine(string.Format("!{0} has {1} digits", k, LeftFactorial(k).ToString().Length));
            }

            Console.ReadKey();
        }

        private static BigInteger Factorial(int number)
        {
            BigInteger accumulator = 1;

            for (int factor = 1; factor <= number; factor++)
            {
                accumulator *= factor;
            }

            return accumulator;
        }

        private static BigInteger LeftFactorial(int n)
        {
            BigInteger result = 0;

            for (int i = 0; i < n; i++)
            {
                result += Factorial(i);
            }

            return result;
        }
    }
}
Task: Left factorials

C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmp.h>

void mpz_left_fac_ui(mpz_t rop, unsigned long op)
{
    mpz_t t1;
    mpz_init_set_ui(t1, 1);
    mpz_set_ui(rop, 0);

    size_t i;
    for (i = 1; i <= op; ++i) {
        mpz_add(rop, rop, t1);
        mpz_mul_ui(t1, t1, i);
    }

    mpz_clear(t1);
}

size_t mpz_digitcount(mpz_t op)
{
    
    char *t    = mpz_get_str(NULL, 10, op);
    size_t ret = strlen(t);
    free(t);
    return ret;
}

int main(void)
{
    mpz_t t;
    mpz_init(t);
    size_t i;

    for (i = 0; i <= 110; ++i) {
        if (i <= 10 || i % 10 == 0) {
            mpz_left_fac_ui(t, i);
            gmp_printf("!%u = %Zd\n", i, t);
        }
    }

    for (i = 1000; i <= 10000; i += 1000) {
        mpz_left_fac_ui(t, i);
        printf("!%u has %u digits\n", i, mpz_digitcount(t));
    }

    mpz_clear(t);
    return 0;
}




Go: package main

import (
    "fmt"
    "math/big"
)

func main() {
    fmt.Print("!0 through !10: 0")
    one := big.NewInt(1)
    n := big.NewInt(1)
    f := big.NewInt(1)
    l := big.NewInt(1)
    next := func() { f.Mul(f, n); l.Add(l, f); n.Add(n, one) }
    for ; ; next() {
        fmt.Print(" ", l)
        if n.Int64() == 10 {
            break
        }
    }
    fmt.Println()
    for {
        for i := 0; i < 10; i++ {
            next()
        }
        fmt.Printf("!%d: %d\n", n, l)
        if n.Int64() == 110 {
            break
        }
    }
    fmt.Println("Lengths of !1000 through !10000 by thousands:")
    for i := 110; i < 1000; i++ {
        next()
    }
    for {
        fmt.Print(" ", len(l.String()))
        if n.Int64() == 10000 {
            break
        }
        for i := 0; i < 1000; i++ {
            next()
        }
    }
    fmt.Println()
}
Task: Left factorials

C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmp.h>

void mpz_left_fac_ui(mpz_t rop, unsigned long op)
{
    mpz_t t1;
    mpz_init_set_ui(t1, 1);
    mpz_set_ui(rop, 0);

    size_t i;
    for (i = 1; i <= op; ++i) {
        mpz_add(rop, rop, t1);
        mpz_mul_ui(t1, t1, i);
    }

    mpz_clear(t1);
}

size_t mpz_digitcount(mpz_t op)
{
    
    char *t    = mpz_get_str(NULL, 10, op);
    size_t ret = strlen(t);
    free(t);
    return ret;
}

int main(void)
{
    mpz_t t;
    mpz_init(t);
    size_t i;

    for (i = 0; i <= 110; ++i) {
        if (i <= 10 || i % 10 == 0) {
            mpz_left_fac_ui(t, i);
            gmp_printf("!%u = %Zd\n", i, t);
        }
    }

    for (i = 1000; i <= 10000; i += 1000) {
        mpz_left_fac_ui(t, i);
        printf("!%u has %u digits\n", i, mpz_digitcount(t));
    }

    mpz_clear(t);
    return 0;
}





Java: import java.math.BigInteger;

public class LeftFac{
	public static BigInteger factorial(BigInteger n){
		BigInteger ans = BigInteger.ONE;
		for(BigInteger x = BigInteger.ONE; x.compareTo(n) <= 0; x = x.add(BigInteger.ONE)){
			ans = ans.multiply(x);
		}
		return ans;
	}
	
	public static BigInteger leftFact(BigInteger n){
		BigInteger ans = BigInteger.ZERO;
		for(BigInteger k = BigInteger.ZERO; k.compareTo(n.subtract(BigInteger.ONE)) <= 0; k = k.add(BigInteger.ONE)){
			ans = ans.add(factorial(k));
		}
		return ans;
	}
	
	public static void main(String[] args){
		for(int i = 0; i <= 10; i++){
			System.out.println("!" + i + " = " + leftFact(BigInteger.valueOf(i)));
		}
		
		for(int i = 20; i <= 110; i += 10){
			System.out.println("!" + i + " = " + leftFact(BigInteger.valueOf(i)));
		}
		
		for(int i = 1000; i <= 10000; i += 1000){
			System.out.println("!" + i + " has " + leftFact(BigInteger.valueOf(i)).toString().length() + " digits");
		}
	}
}
Task: Left factorials

C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmp.h>

void mpz_left_fac_ui(mpz_t rop, unsigned long op)
{
    mpz_t t1;
    mpz_init_set_ui(t1, 1);
    mpz_set_ui(rop, 0);

    size_t i;
    for (i = 1; i <= op; ++i) {
        mpz_add(rop, rop, t1);
        mpz_mul_ui(t1, t1, i);
    }

    mpz_clear(t1);
}

size_t mpz_digitcount(mpz_t op)
{
    
    char *t    = mpz_get_str(NULL, 10, op);
    size_t ret = strlen(t);
    free(t);
    return ret;
}

int main(void)
{
    mpz_t t;
    mpz_init(t);
    size_t i;

    for (i = 0; i <= 110; ++i) {
        if (i <= 10 || i % 10 == 0) {
            mpz_left_fac_ui(t, i);
            gmp_printf("!%u = %Zd\n", i, t);
        }
    }

    for (i = 1000; i <= 10000; i += 1000) {
        mpz_left_fac_ui(t, i);
        printf("!%u has %u digits\n", i, mpz_digitcount(t));
    }

    mpz_clear(t);
    return 0;
}







Python: from itertools import islice

def lfact():
    yield 0
    fact, summ, n = 1, 0, 1 
    while 1:
        fact, summ, n = fact*n, summ + fact, n + 1
        yield summ

print('first 11:\n  %r' % [lf for i, lf in zip(range(11), lfact())])
print('20 through 110 (inclusive) by tens:')
for lf in islice(lfact(), 20, 111, 10):
    print(lf)
print('Digits in 1,000 through 10,000 (inclusive) by thousands:\n  %r' 
      % [len(str(lf)) for lf in islice(lfact(), 1000, 10001, 1000)] )
Task: Left factorials



C#: using System;
using System.Numerics;

namespace LeftFactorial
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i <= 10; i++)
            {
                Console.WriteLine(string.Format("!{0} = {1}", i, LeftFactorial(i)));
            }

            for (int j = 20; j <= 110; j += 10)
            {
                Console.WriteLine(string.Format("!{0} = {1}", j, LeftFactorial(j)));
            }

            for (int k = 1000; k <= 10000; k += 1000)
            {
                Console.WriteLine(string.Format("!{0} has {1} digits", k, LeftFactorial(k).ToString().Length));
            }

            Console.ReadKey();
        }

        private static BigInteger Factorial(int number)
        {
            BigInteger accumulator = 1;

            for (int factor = 1; factor <= number; factor++)
            {
                accumulator *= factor;
            }

            return accumulator;
        }

        private static BigInteger LeftFactorial(int n)
        {
            BigInteger result = 0;

            for (int i = 0; i < n; i++)
            {
                result += Factorial(i);
            }

            return result;
        }
    }
}


Go: package main

import (
    "fmt"
    "math/big"
)

func main() {
    fmt.Print("!0 through !10: 0")
    one := big.NewInt(1)
    n := big.NewInt(1)
    f := big.NewInt(1)
    l := big.NewInt(1)
    next := func() { f.Mul(f, n); l.Add(l, f); n.Add(n, one) }
    for ; ; next() {
        fmt.Print(" ", l)
        if n.Int64() == 10 {
            break
        }
    }
    fmt.Println()
    for {
        for i := 0; i < 10; i++ {
            next()
        }
        fmt.Printf("!%d: %d\n", n, l)
        if n.Int64() == 110 {
            break
        }
    }
    fmt.Println("Lengths of !1000 through !10000 by thousands:")
    for i := 110; i < 1000; i++ {
        next()
    }
    for {
        fmt.Print(" ", len(l.String()))
        if n.Int64() == 10000 {
            break
        }
        for i := 0; i < 1000; i++ {
            next()
        }
    }
    fmt.Println()
}