kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Semordnilap
C: #include <stdio.h>
#include <stdlib.h>
#include <alloca.h> 
#include <string.h>

static void reverse(char *s, int len)
{
    int i, j;
    char tmp;

    for (i = 0, j = len - 1; i < len / 2; ++i, --j)
        tmp = s[i], s[i] = s[j], s[j] = tmp;
}


static int strsort(const void *s1, const void *s2)
{
    return strcmp(*(char *const *) s1, *(char *const *) s2);
}

int main(void)
{
    int i, c, ct = 0, len, sem = 0;
    char **words, **drows, tmp[24];
    FILE *dict = fopen("unixdict.txt", "r");

    
    while ((c = fgetc(dict)) != EOF)
        ct += c == '\n';
    rewind(dict);

    
    words = alloca(ct * sizeof words);
    drows = alloca(ct * sizeof drows);

    for (i = 0; fscanf(dict, "%s%n", tmp, &len) != EOF; ++i) {
        
        strcpy(words[i] = alloca(len), tmp);

        
        strcpy(drows[i] = alloca(len), tmp);
        reverse(drows[i], len - 1);
    }

    fclose(dict);
    qsort(drows, ct, sizeof drows, strsort);

    
    for (c = i = 0; i < ct; ++i) {
        while (strcmp(drows[i], words[c]) > 0 && c < ct - 1)
            c++;
        
        if (!strcmp(drows[i], words[c])) {
            strcpy(tmp, drows[i]);
            reverse(tmp, strlen(tmp));
            
            if (strcmp(drows[i], tmp) > 0 && sem++ < 5)
                printf("%s\t%s\n", drows[i], tmp);
        }
    }

    printf("Semordnilap pairs: %d\n", sem);
    return 0;
}

Python: >>> with open('unixdict.txt') as f:
	wordset = set(f.read().strip().split())

>>> revlist = (''.join(word[::-1]) for word in wordset)
>>> pairs   = set((word, rev) for word, rev in zip(wordset, revlist) 
                  if word < rev and rev in wordset)
>>> len(pairs)
158
>>> sorted(pairs, key=lambda p: (len(p[0]), p))[-5:]
[('damon', 'nomad'), ('lager', 'regal'), ('leper', 'repel'), ('lever', 'revel'), ('kramer', 'remark')]
>>>
Task: Semordnilap
C#: using System;
using System.Net;
using System.Collections.Generic;
using System.Linq;
using System.IO;

public class Semordnilap
{
    public static void Main() {
        var results = FindSemordnilaps("http:
        Console.WriteLine(results.Count);
        var random = new Random();
        Console.WriteLine("5 random results:");
        foreach (string s in results.OrderBy(_ => random.Next()).Distinct().Take(5)) Console.WriteLine(s + " " + Reversed(s));
    }
    
    private static IEnumerable<string> FindSemordnilaps(string url) {
        var found = new HashSet<string>();
        foreach (string line in GetLines(url)) {
            string reversed = Reversed(line);
            
            if (line.CompareTo(reversed) != 0) {
                if (found.Remove(reversed)) yield return reversed;
                else found.Add(line);
            }
        }
    }
    
    private static IEnumerable<string> GetLines(string url) {
        WebRequest request = WebRequest.Create(url);
        using (var reader = new StreamReader(request.GetResponse().GetResponseStream(), true)) {
            while (!reader.EndOfStream) {
                yield return reader.ReadLine();
            }
        }
    }
    
    private static string Reversed(string value) => new string(value.Reverse().ToArray());
}

Java: import java.nio.file.*;
import java.util.*;

public class Semordnilap {

    public static void main(String[] args) throws Exception {
        List<String> lst = Files.readAllLines(Paths.get("unixdict.txt"));
        Set<String> seen = new HashSet<>();
        int count = 0;
        for (String w : lst) {
            w = w.toLowerCase();
            String r = new StringBuilder(w).reverse().toString();
            if (seen.contains(r)) {
                if (count++ < 5)
                    System.out.printf("%-10s %-10s\n", w, r);
            } else seen.add(w);
        }
        System.out.println("\nSemordnilap pairs found: " + count);
    }
}
Task: Semordnilap
C: #include <stdio.h>
#include <stdlib.h>
#include <alloca.h> 
#include <string.h>

static void reverse(char *s, int len)
{
    int i, j;
    char tmp;

    for (i = 0, j = len - 1; i < len / 2; ++i, --j)
        tmp = s[i], s[i] = s[j], s[j] = tmp;
}


static int strsort(const void *s1, const void *s2)
{
    return strcmp(*(char *const *) s1, *(char *const *) s2);
}

int main(void)
{
    int i, c, ct = 0, len, sem = 0;
    char **words, **drows, tmp[24];
    FILE *dict = fopen("unixdict.txt", "r");

    
    while ((c = fgetc(dict)) != EOF)
        ct += c == '\n';
    rewind(dict);

    
    words = alloca(ct * sizeof words);
    drows = alloca(ct * sizeof drows);

    for (i = 0; fscanf(dict, "%s%n", tmp, &len) != EOF; ++i) {
        
        strcpy(words[i] = alloca(len), tmp);

        
        strcpy(drows[i] = alloca(len), tmp);
        reverse(drows[i], len - 1);
    }

    fclose(dict);
    qsort(drows, ct, sizeof drows, strsort);

    
    for (c = i = 0; i < ct; ++i) {
        while (strcmp(drows[i], words[c]) > 0 && c < ct - 1)
            c++;
        
        if (!strcmp(drows[i], words[c])) {
            strcpy(tmp, drows[i]);
            reverse(tmp, strlen(tmp));
            
            if (strcmp(drows[i], tmp) > 0 && sem++ < 5)
                printf("%s\t%s\n", drows[i], tmp);
        }
    }

    printf("Semordnilap pairs: %d\n", sem);
    return 0;
}

PHP: <?php

$dictionary = array_fill_keys(file(
    'http://www.puzzlers.org/pub/wordlists/unixdict.txt',
    FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES
), true);
foreach (array_keys($dictionary) as $word) {
    $reversed_word = strrev($word);
    if (isset($dictionary[$reversed_word]) && $word > $reversed_word)
        $words[$word] = $reversed_word;
}
echo count($words), "\n";

foreach (array_rand($words, 5) as $word)
    echo "$word $words[$word]\n";
Task: Semordnilap
C#: using System;
using System.Net;
using System.Collections.Generic;
using System.Linq;
using System.IO;

public class Semordnilap
{
    public static void Main() {
        var results = FindSemordnilaps("http:
        Console.WriteLine(results.Count);
        var random = new Random();
        Console.WriteLine("5 random results:");
        foreach (string s in results.OrderBy(_ => random.Next()).Distinct().Take(5)) Console.WriteLine(s + " " + Reversed(s));
    }
    
    private static IEnumerable<string> FindSemordnilaps(string url) {
        var found = new HashSet<string>();
        foreach (string line in GetLines(url)) {
            string reversed = Reversed(line);
            
            if (line.CompareTo(reversed) != 0) {
                if (found.Remove(reversed)) yield return reversed;
                else found.Add(line);
            }
        }
    }
    
    private static IEnumerable<string> GetLines(string url) {
        WebRequest request = WebRequest.Create(url);
        using (var reader = new StreamReader(request.GetResponse().GetResponseStream(), true)) {
            while (!reader.EndOfStream) {
                yield return reader.ReadLine();
            }
        }
    }
    
    private static string Reversed(string value) => new string(value.Reverse().ToArray());
}

PHP: <?php

$dictionary = array_fill_keys(file(
    'http://www.puzzlers.org/pub/wordlists/unixdict.txt',
    FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES
), true);
foreach (array_keys($dictionary) as $word) {
    $reversed_word = strrev($word);
    if (isset($dictionary[$reversed_word]) && $word > $reversed_word)
        $words[$word] = $reversed_word;
}
echo count($words), "\n";

foreach (array_rand($words, 5) as $word)
    echo "$word $words[$word]\n";
Task: Semordnilap
C++: #include <fstream>
#include <iostream>
#include <set>
#include <string>

int main() {
    std::ifstream input("unixdict.txt");
    if (input) {
        std::set<std::string> words; 
        std::string word; 
        size_t count = 0; 

        while (input >> word) {
            std::string drow(word.rbegin(), word.rend()); 
            if (words.find(drow) == words.end()) {
                
                words.insert(word);
            } else {
                
                if (count++ < 5)
                    std::cout << word << ' ' << drow << '\n';
            }
        }
        std::cout << "\nSemordnilap pairs: " << count << '\n';
        return 0;
    } else
        return 1; 
}

PHP: <?php

$dictionary = array_fill_keys(file(
    'http://www.puzzlers.org/pub/wordlists/unixdict.txt',
    FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES
), true);
foreach (array_keys($dictionary) as $word) {
    $reversed_word = strrev($word);
    if (isset($dictionary[$reversed_word]) && $word > $reversed_word)
        $words[$word] = $reversed_word;
}
echo count($words), "\n";

foreach (array_rand($words, 5) as $word)
    echo "$word $words[$word]\n";
Task: Semordnilap
Go: package main

import (
    "fmt"
    "io/ioutil"
    "log"
    "strings"
)

func main() {
    
    data, err := ioutil.ReadFile("unixdict.txt")
    if err != nil {
        log.Fatal(err)
    }
    
    words := strings.Split(string(data), "\n")
    
    data = nil
    
    m := make(map[string]bool)
    longest := 0
    for _, w := range words {
        m[string(w)] = true
        if len(w) > longest {
            longest = len(w)
        }
    }
    
    r := make([]byte, longest)
    
    sem := 0
    var five []string
    for _, w := range words {
        
        
        delete(m, w)
        
        last := len(w) - 1
        for i := 0; i < len(w); i++ {
            r[i] = w[last-i]
        }
        rs := string(r[:len(w)])
        
        if m[rs] {
            sem++
            if len(five) < 5 {
                five = append(five, w+"/"+rs)
            }
        }
    }
    
    fmt.Println(sem, "pairs")
    fmt.Println("examples:")
    for _, e := range five {
        fmt.Println("  ", e)
    }
}

PHP: <?php

$dictionary = array_fill_keys(file(
    'http://www.puzzlers.org/pub/wordlists/unixdict.txt',
    FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES
), true);
foreach (array_keys($dictionary) as $word) {
    $reversed_word = strrev($word);
    if (isset($dictionary[$reversed_word]) && $word > $reversed_word)
        $words[$word] = $reversed_word;
}
echo count($words), "\n";

foreach (array_rand($words, 5) as $word)
    echo "$word $words[$word]\n";
Task: Semordnilap
Java: import java.nio.file.*;
import java.util.*;

public class Semordnilap {

    public static void main(String[] args) throws Exception {
        List<String> lst = Files.readAllLines(Paths.get("unixdict.txt"));
        Set<String> seen = new HashSet<>();
        int count = 0;
        for (String w : lst) {
            w = w.toLowerCase();
            String r = new StringBuilder(w).reverse().toString();
            if (seen.contains(r)) {
                if (count++ < 5)
                    System.out.printf("%-10s %-10s\n", w, r);
            } else seen.add(w);
        }
        System.out.println("\nSemordnilap pairs found: " + count);
    }
}

PHP: <?php

$dictionary = array_fill_keys(file(
    'http://www.puzzlers.org/pub/wordlists/unixdict.txt',
    FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES
), true);
foreach (array_keys($dictionary) as $word) {
    $reversed_word = strrev($word);
    if (isset($dictionary[$reversed_word]) && $word > $reversed_word)
        $words[$word] = $reversed_word;
}
echo count($words), "\n";

foreach (array_rand($words, 5) as $word)
    echo "$word $words[$word]\n";
Task: Semordnilap
Python: >>> with open('unixdict.txt') as f:
	wordset = set(f.read().strip().split())

>>> revlist = (''.join(word[::-1]) for word in wordset)
>>> pairs   = set((word, rev) for word, rev in zip(wordset, revlist) 
                  if word < rev and rev in wordset)
>>> len(pairs)
158
>>> sorted(pairs, key=lambda p: (len(p[0]), p))[-5:]
[('damon', 'nomad'), ('lager', 'regal'), ('leper', 'repel'), ('lever', 'revel'), ('kramer', 'remark')]
>>>

PHP: <?php

$dictionary = array_fill_keys(file(
    'http://www.puzzlers.org/pub/wordlists/unixdict.txt',
    FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES
), true);
foreach (array_keys($dictionary) as $word) {
    $reversed_word = strrev($word);
    if (isset($dictionary[$reversed_word]) && $word > $reversed_word)
        $words[$word] = $reversed_word;
}
echo count($words), "\n";

foreach (array_rand($words, 5) as $word)
    echo "$word $words[$word]\n";
Task: Semordnilap
VB: Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInFile = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_
		"\unixdict.txt",1)

Set objUnixDict = CreateObject("Scripting.Dictionary")
Set objSemordnilap = CreateObject("Scripting.Dictionary")

Do Until objInFile.AtEndOfStream
	line = objInFile.ReadLine
	If Len(line) > 1 Then
		objUnixDict.Add line,""
	End If
	reverse_line = StrReverse(line)
	If reverse_line <> line And objUnixDict.Exists(reverse_line) Then
		objSemordnilap.Add line, reverse_line
	End If
Loop	


k = 0
For Each Key In objSemordnilap.Keys
	WScript.StdOut.Write Key & " - " & objSemordnilap.Item(Key)
	WScript.StdOut.WriteLine
	k = k + 1
	If k = 5 Then
		Exit For
	End If
Next

WScript.StdOut.Write "Total Count:  " & objSemordnilap.Count
WScript.StdOut.WriteLine

objInFile.Close
Set objFSO = Nothing
Set objUnixDict = Nothing
Set objSemordnilap = Nothing

PHP: <?php

$dictionary = array_fill_keys(file(
    'http://www.puzzlers.org/pub/wordlists/unixdict.txt',
    FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES
), true);
foreach (array_keys($dictionary) as $word) {
    $reversed_word = strrev($word);
    if (isset($dictionary[$reversed_word]) && $word > $reversed_word)
        $words[$word] = $reversed_word;
}
echo count($words), "\n";

foreach (array_rand($words, 5) as $word)
    echo "$word $words[$word]\n";
Task: Factorial
C: int factorial(int n) {
    int result = 1;
    for (int i = 1; i <= n; ++i)
        result *= i;
    return result;
}

C#: using System;

class Program
{
    static int Factorial(int number)
    {
        if(number < 0) 
            throw new ArgumentOutOfRangeException(nameof(number), number, "Must be zero or a positive number.");

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

    static void Main()
    {
        Console.WriteLine(Factorial(10));
    }
}
Task: Factorial
C: int factorial(int n) {
    int result = 1;
    for (int i = 1; i <= n; ++i)
        result *= i;
    return result;
}

C++: #include <boost/iterator/counting_iterator.hpp>
#include <algorithm>

int factorial(int n)
{
  
  return std::accumulate(boost::counting_iterator<int>(1), boost::counting_iterator<int>(n+1), 1, std::multiplies<int>());
}
Task: Factorial
C: int factorial(int n) {
    int result = 1;
    for (int i = 1; i <= n; ++i)
        result *= i;
    return result;
}

Go: package main

import (
    "fmt"
    "math/big"
)

func main() {
    fmt.Println(factorial(800))
}

func factorial(n int64) *big.Int {
    if n < 0 {
        return nil
    }
    r := big.NewInt(1)
    var f big.Int
    for i := int64(2); i <= n; i++ {
        r.Mul(r, f.SetInt64(i))
    }
    return r
}
Task: Factorial
C: int factorial(int n) {
    int result = 1;
    for (int i = 1; i <= n; ++i)
        result *= i;
    return result;
}

Python: import math
math.factorial(n)
Task: Factorial
C: int factorial(int n) {
    int result = 1;
    for (int i = 1; i <= n; ++i)
        result *= i;
    return result;
}

VB: print "enter a number, n = ";
input n
print string(n) + "! = " + string(factorial(n))

function factorial(n)
   factorial = 1
   if n > 0 then
      for p = 1 to n
      factorial *= p
      next p
   end if
end function
Task: Factorial
C#: using System;

class Program
{
    static int Factorial(int number)
    {
        if(number < 0) 
            throw new ArgumentOutOfRangeException(nameof(number), number, "Must be zero or a positive number.");

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

    static void Main()
    {
        Console.WriteLine(Factorial(10));
    }
}

C++: #include <boost/iterator/counting_iterator.hpp>
#include <algorithm>

int factorial(int n)
{
  
  return std::accumulate(boost::counting_iterator<int>(1), boost::counting_iterator<int>(n+1), 1, std::multiplies<int>());
}
Task: Factorial
C++: #include <boost/iterator/counting_iterator.hpp>
#include <algorithm>

int factorial(int n)
{
  
  return std::accumulate(boost::counting_iterator<int>(1), boost::counting_iterator<int>(n+1), 1, std::multiplies<int>());
}

Go: package main

import (
    "fmt"
    "math/big"
)

func main() {
    fmt.Println(factorial(800))
}

func factorial(n int64) *big.Int {
    if n < 0 {
        return nil
    }
    r := big.NewInt(1)
    var f big.Int
    for i := int64(2); i <= n; i++ {
        r.Mul(r, f.SetInt64(i))
    }
    return r
}
Task: Factorial
C++: #include <boost/iterator/counting_iterator.hpp>
#include <algorithm>

int factorial(int n)
{
  
  return std::accumulate(boost::counting_iterator<int>(1), boost::counting_iterator<int>(n+1), 1, std::multiplies<int>());
}

Java: module ShowFactorials
    {
    static <Value extends IntNumber> Value factorial(Value n)
        {
        assert:arg n >= Value.zero();
        return n <= Value.one() ? n : n * factorial(n-Value.one());
        }

    @Inject Console console;
    void run()
        {
        
        UInt128 bigNum = 34;
        console.print($"factorial({bigNum})={factorial(bigNum)}");

        
        for (Int i : 10..-1)
            {
            console.print($"factorial({i})={factorial(i)}");
            }
        }
    }
Task: Factorial
C#: using System;

class Program
{
    static int Factorial(int number)
    {
        if(number < 0) 
            throw new ArgumentOutOfRangeException(nameof(number), number, "Must be zero or a positive number.");

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

    static void Main()
    {
        Console.WriteLine(Factorial(10));
    }
}

Go: package main

import (
    "fmt"
    "math/big"
)

func main() {
    fmt.Println(factorial(800))
}

func factorial(n int64) *big.Int {
    if n < 0 {
        return nil
    }
    r := big.NewInt(1)
    var f big.Int
    for i := int64(2); i <= n; i++ {
        r.Mul(r, f.SetInt64(i))
    }
    return r
}
Task: Factorial
C#: using System;

class Program
{
    static int Factorial(int number)
    {
        if(number < 0) 
            throw new ArgumentOutOfRangeException(nameof(number), number, "Must be zero or a positive number.");

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

    static void Main()
    {
        Console.WriteLine(Factorial(10));
    }
}

Python: import math
math.factorial(n)
Task: Factorial
Go: package main

import (
    "fmt"
    "math/big"
)

func main() {
    fmt.Println(factorial(800))
}

func factorial(n int64) *big.Int {
    if n < 0 {
        return nil
    }
    r := big.NewInt(1)
    var f big.Int
    for i := int64(2); i <= n; i++ {
        r.Mul(r, f.SetInt64(i))
    }
    return r
}

Java: module ShowFactorials
    {
    static <Value extends IntNumber> Value factorial(Value n)
        {
        assert:arg n >= Value.zero();
        return n <= Value.one() ? n : n * factorial(n-Value.one());
        }

    @Inject Console console;
    void run()
        {
        
        UInt128 bigNum = 34;
        console.print($"factorial({bigNum})={factorial(bigNum)}");

        
        for (Int i : 10..-1)
            {
            console.print($"factorial({i})={factorial(i)}");
            }
        }
    }
Task: Factorial
Java: module ShowFactorials
    {
    static <Value extends IntNumber> Value factorial(Value n)
        {
        assert:arg n >= Value.zero();
        return n <= Value.one() ? n : n * factorial(n-Value.one());
        }

    @Inject Console console;
    void run()
        {
        
        UInt128 bigNum = 34;
        console.print($"factorial({bigNum})={factorial(bigNum)}");

        
        for (Int i : 10..-1)
            {
            console.print($"factorial({i})={factorial(i)}");
            }
        }
    }

Python: import math
math.factorial(n)
Task: Factorial
Go: package main

import (
    "fmt"
    "math/big"
)

func main() {
    fmt.Println(factorial(800))
}

func factorial(n int64) *big.Int {
    if n < 0 {
        return nil
    }
    r := big.NewInt(1)
    var f big.Int
    for i := int64(2); i <= n; i++ {
        r.Mul(r, f.SetInt64(i))
    }
    return r
}

Python: import math
math.factorial(n)
Task: Factorial
Go: package main

import (
    "fmt"
    "math/big"
)

func main() {
    fmt.Println(factorial(800))
}

func factorial(n int64) *big.Int {
    if n < 0 {
        return nil
    }
    r := big.NewInt(1)
    var f big.Int
    for i := int64(2); i <= n; i++ {
        r.Mul(r, f.SetInt64(i))
    }
    return r
}

VB: print "enter a number, n = ";
input n
print string(n) + "! = " + string(factorial(n))

function factorial(n)
   factorial = 1
   if n > 0 then
      for p = 1 to n
      factorial *= p
      next p
   end if
end function
Task: Factorial
Python: import math
math.factorial(n)

VB: print "enter a number, n = ";
input n
print string(n) + "! = " + string(factorial(n))

function factorial(n)
   factorial = 1
   if n > 0 then
      for p = 1 to n
      factorial *= p
      next p
   end if
end function
Task: Factorial
C: int factorial(int n) {
    int result = 1;
    for (int i = 1; i <= n; ++i)
        result *= i;
    return result;
}

Java: module ShowFactorials
    {
    static <Value extends IntNumber> Value factorial(Value n)
        {
        assert:arg n >= Value.zero();
        return n <= Value.one() ? n : n * factorial(n-Value.one());
        }

    @Inject Console console;
    void run()
        {
        
        UInt128 bigNum = 34;
        console.print($"factorial({bigNum})={factorial(bigNum)}");

        
        for (Int i : 10..-1)
            {
            console.print($"factorial({i})={factorial(i)}");
            }
        }
    }
Task: Factorial
C++: #include <boost/iterator/counting_iterator.hpp>
#include <algorithm>

int factorial(int n)
{
  
  return std::accumulate(boost::counting_iterator<int>(1), boost::counting_iterator<int>(n+1), 1, std::multiplies<int>());
}

Python: import math
math.factorial(n)
Task: Factorial
C++: #include <boost/iterator/counting_iterator.hpp>
#include <algorithm>

int factorial(int n)
{
  
  return std::accumulate(boost::counting_iterator<int>(1), boost::counting_iterator<int>(n+1), 1, std::multiplies<int>());
}

VB: print "enter a number, n = ";
input n
print string(n) + "! = " + string(factorial(n))

function factorial(n)
   factorial = 1
   if n > 0 then
      for p = 1 to n
      factorial *= p
      next p
   end if
end function
Task: Factorial
C#: using System;

class Program
{
    static int Factorial(int number)
    {
        if(number < 0) 
            throw new ArgumentOutOfRangeException(nameof(number), number, "Must be zero or a positive number.");

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

    static void Main()
    {
        Console.WriteLine(Factorial(10));
    }
}

VB: print "enter a number, n = ";
input n
print string(n) + "! = " + string(factorial(n))

function factorial(n)
   factorial = 1
   if n > 0 then
      for p = 1 to n
      factorial *= p
      next p
   end if
end function