WeixiangYan/CodeTransOcean huggingface dataset:
Task: Isqrt (integer square root) of X



C#: using System;
using static System.Console;
using BI = System.Numerics.BigInteger;
 
class Program {
 
    static BI isqrt(BI x) { BI q = 1, r = 0, t; while (q <= x) q <<= 2; while (q > 1) {
        q >>= 2; t = x - r - q; r >>= 1; if (t >= 0) { x = t; r += q; } } return r; }
 
    static void Main() { const int max = 73, smax = 65;
        int power_width = ((BI.Pow(7, max).ToString().Length / 3) << 2) + 3,
            isqrt_width = (power_width + 1) >> 1;
        WriteLine("Integer square root for numbers 0 to {0}:", smax);
        for (int n = 0; n <= smax; ++n) Write("{0} ", 
            (n / 10).ToString().Replace("0", " ")); WriteLine();
        for (int n = 0; n <= smax; ++n) Write("{0} ", n % 10); WriteLine();
        WriteLine(new String('-', (smax << 1) + 1));
        for (int n = 0; n <= smax; ++n) Write("{0} ", isqrt(n));
        WriteLine("\n\nInteger square roots of odd powers of 7 from 1 to {0}:", max);
        string s = string.Format("[0,2] |[1,{0}:n0] |[2,{1}:n0]",
            power_width, isqrt_width).Replace("[", "{").Replace("]", "}");
        WriteLine(s, "n", "7 ^ n", "isqrt(7 ^ n)");
        WriteLine(new String('-', power_width + isqrt_width + 6));
        BI p = 7; for (int n = 1; n <= max; n += 2, p *= 49)
            WriteLine (s, n, p, isqrt(p)); }
}



Java: import java.math.BigInteger;

public class Isqrt {
    private static BigInteger isqrt(BigInteger x) {
        if (x.compareTo(BigInteger.ZERO) < 0) {
            throw new IllegalArgumentException("Argument cannot be negative");
        }
        var q = BigInteger.ONE;
        while (q.compareTo(x) <= 0) {
            q = q.shiftLeft(2);
        }
        var z = x;
        var r = BigInteger.ZERO;
        while (q.compareTo(BigInteger.ONE) > 0) {
            q = q.shiftRight(2);
            var t = z;
            t = t.subtract(r);
            t = t.subtract(q);
            r = r.shiftRight(1);
            if (t.compareTo(BigInteger.ZERO) >= 0) {
                z = t;
                r = r.add(q);
            }
        }
        return r;
    }

    public static void main(String[] args) {
        System.out.println("The integer square root of integers from 0 to 65 are:");
        for (int i = 0; i <= 65; i++) {
            System.out.printf("%s ", isqrt(BigInteger.valueOf(i)));
        }
        System.out.println();

        System.out.println("The integer square roots of powers of 7 from 7^1 up to 7^73 are:");
        System.out.println("power                                    7 ^ power                                                 integer square root");
        System.out.println("----- --------------------------------------------------------------------------------- -----------------------------------------");
        var pow7 = BigInteger.valueOf(7);
        var bi49 = BigInteger.valueOf(49);
        for (int i = 1; i < 74; i += 2) {
            System.out.printf("%2d %,84d %,41d\n", i, pow7, isqrt(pow7));
            pow7 = pow7.multiply(bi49);
        }
    }
}
Task: Isqrt (integer square root) of X



C#: using System;
using static System.Console;
using BI = System.Numerics.BigInteger;
 
class Program {
 
    static BI isqrt(BI x) { BI q = 1, r = 0, t; while (q <= x) q <<= 2; while (q > 1) {
        q >>= 2; t = x - r - q; r >>= 1; if (t >= 0) { x = t; r += q; } } return r; }
 
    static void Main() { const int max = 73, smax = 65;
        int power_width = ((BI.Pow(7, max).ToString().Length / 3) << 2) + 3,
            isqrt_width = (power_width + 1) >> 1;
        WriteLine("Integer square root for numbers 0 to {0}:", smax);
        for (int n = 0; n <= smax; ++n) Write("{0} ", 
            (n / 10).ToString().Replace("0", " ")); WriteLine();
        for (int n = 0; n <= smax; ++n) Write("{0} ", n % 10); WriteLine();
        WriteLine(new String('-', (smax << 1) + 1));
        for (int n = 0; n <= smax; ++n) Write("{0} ", isqrt(n));
        WriteLine("\n\nInteger square roots of odd powers of 7 from 1 to {0}:", max);
        string s = string.Format("[0,2] |[1,{0}:n0] |[2,{1}:n0]",
            power_width, isqrt_width).Replace("[", "{").Replace("]", "}");
        WriteLine(s, "n", "7 ^ n", "isqrt(7 ^ n)");
        WriteLine(new String('-', power_width + isqrt_width + 6));
        BI p = 7; for (int n = 1; n <= max; n += 2, p *= 49)
            WriteLine (s, n, p, isqrt(p)); }
}





Python: def isqrt ( x ):
    q = 1
    while q <= x : 
        q *= 4
    z,r = x,0
    while q > 1 :
        q  /= 4
        t,r = z-r-q,r/2
        if t >= 0 :
            z,r = t,r+q
    return r 

print ' '.join( '%d'%isqrt( n ) for n in xrange( 66 ))
print '\n'.join( '{0:114,} = isqrt( 7^{1:3} )'.format( isqrt( 7**n ),n ) for n in range( 1,204,2 ))
Task: Isqrt (integer square root) of X



C#: using System;
using static System.Console;
using BI = System.Numerics.BigInteger;
 
class Program {
 
    static BI isqrt(BI x) { BI q = 1, r = 0, t; while (q <= x) q <<= 2; while (q > 1) {
        q >>= 2; t = x - r - q; r >>= 1; if (t >= 0) { x = t; r += q; } } return r; }
 
    static void Main() { const int max = 73, smax = 65;
        int power_width = ((BI.Pow(7, max).ToString().Length / 3) << 2) + 3,
            isqrt_width = (power_width + 1) >> 1;
        WriteLine("Integer square root for numbers 0 to {0}:", smax);
        for (int n = 0; n <= smax; ++n) Write("{0} ", 
            (n / 10).ToString().Replace("0", " ")); WriteLine();
        for (int n = 0; n <= smax; ++n) Write("{0} ", n % 10); WriteLine();
        WriteLine(new String('-', (smax << 1) + 1));
        for (int n = 0; n <= smax; ++n) Write("{0} ", isqrt(n));
        WriteLine("\n\nInteger square roots of odd powers of 7 from 1 to {0}:", max);
        string s = string.Format("[0,2] |[1,{0}:n0] |[2,{1}:n0]",
            power_width, isqrt_width).Replace("[", "{").Replace("]", "}");
        WriteLine(s, "n", "7 ^ n", "isqrt(7 ^ n)");
        WriteLine(new String('-', power_width + isqrt_width + 6));
        BI p = 7; for (int n = 1; n <= max; n += 2, p *= 49)
            WriteLine (s, n, p, isqrt(p)); }
}






VB: Imports System
Imports System.Console
Imports BI = System.Numerics.BigInteger

Module Module1
    Function isqrt(ByVal x As BI) As BI
        Dim t As BI, q As BI = 1, r As BI = 0
        While q <= x : q <<= 2 : End While
        While q > 1 : q >>= 2 : t = x - r - q : r >>= 1
            If t >= 0 Then x = t : r += q
        End While : Return r
    End Function

    Sub Main()
        Const max As Integer = 73, smax As Integer = 65
        Dim power_width As Integer = ((BI.Pow(7, max).ToString().Length \ 3) << 2) + 3,
            isqrt_width As Integer = (power_width + 1) >> 1,
            n as Integer
        WriteLine("Integer square root for numbers 0 to {0}:", smax)
        For n = 0 To smax : Write("{0} ", (n \ 10).ToString().Replace("0", " "))
            Next : WriteLine()
        For n = 0 To smax : Write("{0} ", n Mod 10) : Next : WriteLine()
        WriteLine(New String("-"c, (smax << 1) + 1))
        For n = 0 To smax : Write("{0} ", isqrt(n)) : Next
        WriteLine(vbLf & vbLf & "Integer square roots of odd powers of 7 from 1 to {0}:", max)
        Dim s As String = String.Format("[0,2] |[1,{0}:n0] |[2,{1}:n0]",
            power_width, isqrt_width).Replace("[", "{").Replace("]", "}")
        WriteLine(s, "n", "7 ^ n", "isqrt(7 ^ n)")
        WriteLine(New String("-"c, power_width + isqrt_width + 6))
        Dim p As BI = 7 : n = 1 : While n <= max
            WriteLine(s, n, p, isqrt(p)) : n += 2 : p = p * 49
        End While
    End Sub
End Module
Task: Isqrt (integer square root) of X





Java: import java.math.BigInteger;

public class Isqrt {
    private static BigInteger isqrt(BigInteger x) {
        if (x.compareTo(BigInteger.ZERO) < 0) {
            throw new IllegalArgumentException("Argument cannot be negative");
        }
        var q = BigInteger.ONE;
        while (q.compareTo(x) <= 0) {
            q = q.shiftLeft(2);
        }
        var z = x;
        var r = BigInteger.ZERO;
        while (q.compareTo(BigInteger.ONE) > 0) {
            q = q.shiftRight(2);
            var t = z;
            t = t.subtract(r);
            t = t.subtract(q);
            r = r.shiftRight(1);
            if (t.compareTo(BigInteger.ZERO) >= 0) {
                z = t;
                r = r.add(q);
            }
        }
        return r;
    }

    public static void main(String[] args) {
        System.out.println("The integer square root of integers from 0 to 65 are:");
        for (int i = 0; i <= 65; i++) {
            System.out.printf("%s ", isqrt(BigInteger.valueOf(i)));
        }
        System.out.println();

        System.out.println("The integer square roots of powers of 7 from 7^1 up to 7^73 are:");
        System.out.println("power                                    7 ^ power                                                 integer square root");
        System.out.println("----- --------------------------------------------------------------------------------- -----------------------------------------");
        var pow7 = BigInteger.valueOf(7);
        var bi49 = BigInteger.valueOf(49);
        for (int i = 1; i < 74; i += 2) {
            System.out.printf("%2d %,84d %,41d\n", i, pow7, isqrt(pow7));
            pow7 = pow7.multiply(bi49);
        }
    }
}



Python: def isqrt ( x ):
    q = 1
    while q <= x : 
        q *= 4
    z,r = x,0
    while q > 1 :
        q  /= 4
        t,r = z-r-q,r/2
        if t >= 0 :
            z,r = t,r+q
    return r 

print ' '.join( '%d'%isqrt( n ) for n in xrange( 66 ))
print '\n'.join( '{0:114,} = isqrt( 7^{1:3} )'.format( isqrt( 7**n ),n ) for n in range( 1,204,2 ))
Task: Isqrt (integer square root) of X




Go: package main

import (
    "fmt"
    "log"
    "math/big"
)

var zero = big.NewInt(0)
var one = big.NewInt(1)

func isqrt(x *big.Int) *big.Int {
    if x.Cmp(zero) < 0 {
        log.Fatal("Argument cannot be negative.")
    }
    q := big.NewInt(1)
    for q.Cmp(x) <= 0 {
        q.Lsh(q, 2)
    }
    z := new(big.Int).Set(x)
    r := big.NewInt(0)
    for q.Cmp(one) > 0 {
        q.Rsh(q, 2)
        t := new(big.Int)
        t.Add(t, z)
        t.Sub(t, r)
        t.Sub(t, q)
        r.Rsh(r, 1)
        if t.Cmp(zero) >= 0 {
            z.Set(t)
            r.Add(r, q)
        }
    }
    return r
}

func commatize(s string) string {
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    return s
}

func main() {
    fmt.Println("The integer square roots of integers from 0 to 65 are:")
    for i := int64(0); i <= 65; i++ {
        fmt.Printf("%d ", isqrt(big.NewInt(i)))
    }
    fmt.Println()
    fmt.Println("\nThe integer square roots of powers of 7 from 7^1 up to 7^73 are:\n")
    fmt.Println("power                                    7 ^ power                                                 integer square root")
    fmt.Println("----- --------------------------------------------------------------------------------- -----------------------------------------")
    pow7 := big.NewInt(7)
    bi49 := big.NewInt(49)
    for i := 1; i <= 73; i += 2 {
        fmt.Printf("%2d %84s %41s\n", i, commatize(pow7.String()), commatize(isqrt(pow7).String()))
        pow7.Mul(pow7, bi49)
    }
}




Python: def isqrt ( x ):
    q = 1
    while q <= x : 
        q *= 4
    z,r = x,0
    while q > 1 :
        q  /= 4
        t,r = z-r-q,r/2
        if t >= 0 :
            z,r = t,r+q
    return r 

print ' '.join( '%d'%isqrt( n ) for n in xrange( 66 ))
print '\n'.join( '{0:114,} = isqrt( 7^{1:3} )'.format( isqrt( 7**n ),n ) for n in range( 1,204,2 ))
Task: Isqrt (integer square root) of X




Go: package main

import (
    "fmt"
    "log"
    "math/big"
)

var zero = big.NewInt(0)
var one = big.NewInt(1)

func isqrt(x *big.Int) *big.Int {
    if x.Cmp(zero) < 0 {
        log.Fatal("Argument cannot be negative.")
    }
    q := big.NewInt(1)
    for q.Cmp(x) <= 0 {
        q.Lsh(q, 2)
    }
    z := new(big.Int).Set(x)
    r := big.NewInt(0)
    for q.Cmp(one) > 0 {
        q.Rsh(q, 2)
        t := new(big.Int)
        t.Add(t, z)
        t.Sub(t, r)
        t.Sub(t, q)
        r.Rsh(r, 1)
        if t.Cmp(zero) >= 0 {
            z.Set(t)
            r.Add(r, q)
        }
    }
    return r
}

func commatize(s string) string {
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    return s
}

func main() {
    fmt.Println("The integer square roots of integers from 0 to 65 are:")
    for i := int64(0); i <= 65; i++ {
        fmt.Printf("%d ", isqrt(big.NewInt(i)))
    }
    fmt.Println()
    fmt.Println("\nThe integer square roots of powers of 7 from 7^1 up to 7^73 are:\n")
    fmt.Println("power                                    7 ^ power                                                 integer square root")
    fmt.Println("----- --------------------------------------------------------------------------------- -----------------------------------------")
    pow7 := big.NewInt(7)
    bi49 := big.NewInt(49)
    for i := 1; i <= 73; i += 2 {
        fmt.Printf("%2d %84s %41s\n", i, commatize(pow7.String()), commatize(isqrt(pow7).String()))
        pow7.Mul(pow7, bi49)
    }
}





VB: Imports System
Imports System.Console
Imports BI = System.Numerics.BigInteger

Module Module1
    Function isqrt(ByVal x As BI) As BI
        Dim t As BI, q As BI = 1, r As BI = 0
        While q <= x : q <<= 2 : End While
        While q > 1 : q >>= 2 : t = x - r - q : r >>= 1
            If t >= 0 Then x = t : r += q
        End While : Return r
    End Function

    Sub Main()
        Const max As Integer = 73, smax As Integer = 65
        Dim power_width As Integer = ((BI.Pow(7, max).ToString().Length \ 3) << 2) + 3,
            isqrt_width As Integer = (power_width + 1) >> 1,
            n as Integer
        WriteLine("Integer square root for numbers 0 to {0}:", smax)
        For n = 0 To smax : Write("{0} ", (n \ 10).ToString().Replace("0", " "))
            Next : WriteLine()
        For n = 0 To smax : Write("{0} ", n Mod 10) : Next : WriteLine()
        WriteLine(New String("-"c, (smax << 1) + 1))
        For n = 0 To smax : Write("{0} ", isqrt(n)) : Next
        WriteLine(vbLf & vbLf & "Integer square roots of odd powers of 7 from 1 to {0}:", max)
        Dim s As String = String.Format("[0,2] |[1,{0}:n0] |[2,{1}:n0]",
            power_width, isqrt_width).Replace("[", "{").Replace("]", "}")
        WriteLine(s, "n", "7 ^ n", "isqrt(7 ^ n)")
        WriteLine(New String("-"c, power_width + isqrt_width + 6))
        Dim p As BI = 7 : n = 1 : While n <= max
            WriteLine(s, n, p, isqrt(p)) : n += 2 : p = p * 49
        End While
    End Sub
End Module
Task: Isqrt (integer square root) of X







Python: def isqrt ( x ):
    q = 1
    while q <= x : 
        q *= 4
    z,r = x,0
    while q > 1 :
        q  /= 4
        t,r = z-r-q,r/2
        if t >= 0 :
            z,r = t,r+q
    return r 

print ' '.join( '%d'%isqrt( n ) for n in xrange( 66 ))
print '\n'.join( '{0:114,} = isqrt( 7^{1:3} )'.format( isqrt( 7**n ),n ) for n in range( 1,204,2 ))


VB: Imports System
Imports System.Console
Imports BI = System.Numerics.BigInteger

Module Module1
    Function isqrt(ByVal x As BI) As BI
        Dim t As BI, q As BI = 1, r As BI = 0
        While q <= x : q <<= 2 : End While
        While q > 1 : q >>= 2 : t = x - r - q : r >>= 1
            If t >= 0 Then x = t : r += q
        End While : Return r
    End Function

    Sub Main()
        Const max As Integer = 73, smax As Integer = 65
        Dim power_width As Integer = ((BI.Pow(7, max).ToString().Length \ 3) << 2) + 3,
            isqrt_width As Integer = (power_width + 1) >> 1,
            n as Integer
        WriteLine("Integer square root for numbers 0 to {0}:", smax)
        For n = 0 To smax : Write("{0} ", (n \ 10).ToString().Replace("0", " "))
            Next : WriteLine()
        For n = 0 To smax : Write("{0} ", n Mod 10) : Next : WriteLine()
        WriteLine(New String("-"c, (smax << 1) + 1))
        For n = 0 To smax : Write("{0} ", isqrt(n)) : Next
        WriteLine(vbLf & vbLf & "Integer square roots of odd powers of 7 from 1 to {0}:", max)
        Dim s As String = String.Format("[0,2] |[1,{0}:n0] |[2,{1}:n0]",
            power_width, isqrt_width).Replace("[", "{").Replace("]", "}")
        WriteLine(s, "n", "7 ^ n", "isqrt(7 ^ n)")
        WriteLine(New String("-"c, power_width + isqrt_width + 6))
        Dim p As BI = 7 : n = 1 : While n <= max
            WriteLine(s, n, p, isqrt(p)) : n += 2 : p = p * 49
        End While
    End Sub
End Module
Task: Distinct power numbers

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

int compare(const void *a, const void *b) {
    int ia = *(int*)a;
    int ib = *(int*)b;
    return (ia>ib) - (ia<ib);
}

int main() {
    int pows[16];
    int a, b, i=0;
    
    for (a=2; a<=5; a++)
        for (b=2; b<=5; b++)
            pows[i++] = pow(a, b);
    
    qsort(pows, 16, sizeof(int), compare);
    
    for (i=0; i<16; i++)
        if (i==0 || pows[i] != pows[i-1]) 
            printf("%d ", pows[i]);
    
    printf("\n");
    return 0;
}



C#: #include <iostream>
#include <set>
#include <cmath>

int main() {
    std::set<int> values;
    for (int a=2; a<=5; a++)
        for (int b=2; b<=5; b++)
            values.insert(std::pow(a, b));
    
    for (int i : values)
        std::cout << i << " ";
    
    std::cout << std::endl;
    return 0;
}
Task: Distinct power numbers

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

int compare(const void *a, const void *b) {
    int ia = *(int*)a;
    int ib = *(int*)b;
    return (ia>ib) - (ia<ib);
}

int main() {
    int pows[16];
    int a, b, i=0;
    
    for (a=2; a<=5; a++)
        for (b=2; b<=5; b++)
            pows[i++] = pow(a, b);
    
    qsort(pows, 16, sizeof(int), compare);
    
    for (i=0; i<16; i++)
        if (i==0 || pows[i] != pows[i-1]) 
            printf("%d ", pows[i]);
    
    printf("\n");
    return 0;
}







Python: from itertools import product
print(sorted(set(a**b for (a,b) in product(range(2,6), range(2,6)))))
Task: Distinct power numbers


C++: #include <iostream>
#include <set>
#include <cmath>

int main() {
    std::set<int> values;
    for (int a=2; a<=5; a++)
        for (int b=2; b<=5; b++)
            values.insert(std::pow(a, b));
    
    for (int i : values)
        std::cout << i << " ";
    
    std::cout << std::endl;
    return 0;
}



Go: package main

import (
    "fmt"
    "rcu"
    "sort"
)

func main() {
    var pows []int
    for a := 2; a <= 5; a++ {
        pow := a
        for b := 2; b <= 5; b++ {
            pow *= a
            pows = append(pows, pow)
        }
    }
    set := make(map[int]bool)
    for _, e := range pows {
        set[e] = true
    }
    pows = pows[:0]
    for k := range set {
        pows = append(pows, k)
    }
    sort.Ints(pows)
    fmt.Println("Ordered distinct values of a ^ b for a in [2..5] and b in [2..5]:")
    for i, pow := range pows {
        fmt.Printf("%5s ", rcu.Commatize(pow))
        if (i+1)%5 == 0 {
            fmt.Println()
        }
    }
    fmt.Println("\nFound", len(pows), "such numbers.")
}
Task: Distinct power numbers


C++: #include <iostream>
#include <set>
#include <cmath>

int main() {
    std::set<int> values;
    for (int a=2; a<=5; a++)
        for (int b=2; b<=5; b++)
            values.insert(std::pow(a, b));
    
    for (int i : values)
        std::cout << i << " ";
    
    std::cout << std::endl;
    return 0;
}






Python: from itertools import product
print(sorted(set(a**b for (a,b) in product(range(2,6), range(2,6)))))
Task: Distinct power numbers




Go: package main

import (
    "fmt"
    "rcu"
    "sort"
)

func main() {
    var pows []int
    for a := 2; a <= 5; a++ {
        pow := a
        for b := 2; b <= 5; b++ {
            pow *= a
            pows = append(pows, pow)
        }
    }
    set := make(map[int]bool)
    for _, e := range pows {
        set[e] = true
    }
    pows = pows[:0]
    for k := range set {
        pows = append(pows, k)
    }
    sort.Ints(pows)
    fmt.Println("Ordered distinct values of a ^ b for a in [2..5] and b in [2..5]:")
    for i, pow := range pows {
        fmt.Printf("%5s ", rcu.Commatize(pow))
        if (i+1)%5 == 0 {
            fmt.Println()
        }
    }
    fmt.Println("\nFound", len(pows), "such numbers.")
}




Python: from itertools import product
print(sorted(set(a**b for (a,b) in product(range(2,6), range(2,6)))))
Task: Distinct power numbers

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

int compare(const void *a, const void *b) {
    int ia = *(int*)a;
    int ib = *(int*)b;
    return (ia>ib) - (ia<ib);
}

int main() {
    int pows[16];
    int a, b, i=0;
    
    for (a=2; a<=5; a++)
        for (b=2; b<=5; b++)
            pows[i++] = pow(a, b);
    
    qsort(pows, 16, sizeof(int), compare);
    
    for (i=0; i<16; i++)
        if (i==0 || pows[i] != pows[i-1]) 
            printf("%d ", pows[i]);
    
    printf("\n");
    return 0;
}


C++: #include <iostream>
#include <set>
#include <cmath>

int main() {
    std::set<int> values;
    for (int a=2; a<=5; a++)
        for (int b=2; b<=5; b++)
            values.insert(std::pow(a, b));
    
    for (int i : values)
        std::cout << i << " ";
    
    std::cout << std::endl;
    return 0;
}
Task: Distinct power numbers

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

int compare(const void *a, const void *b) {
    int ia = *(int*)a;
    int ib = *(int*)b;
    return (ia>ib) - (ia<ib);
}

int main() {
    int pows[16];
    int a, b, i=0;
    
    for (a=2; a<=5; a++)
        for (b=2; b<=5; b++)
            pows[i++] = pow(a, b);
    
    qsort(pows, 16, sizeof(int), compare);
    
    for (i=0; i<16; i++)
        if (i==0 || pows[i] != pows[i-1]) 
            printf("%d ", pows[i]);
    
    printf("\n");
    return 0;
}




Go: package main

import (
    "fmt"
    "rcu"
    "sort"
)

func main() {
    var pows []int
    for a := 2; a <= 5; a++ {
        pow := a
        for b := 2; b <= 5; b++ {
            pow *= a
            pows = append(pows, pow)
        }
    }
    set := make(map[int]bool)
    for _, e := range pows {
        set[e] = true
    }
    pows = pows[:0]
    for k := range set {
        pows = append(pows, k)
    }
    sort.Ints(pows)
    fmt.Println("Ordered distinct values of a ^ b for a in [2..5] and b in [2..5]:")
    for i, pow := range pows {
        fmt.Printf("%5s ", rcu.Commatize(pow))
        if (i+1)%5 == 0 {
            fmt.Println()
        }
    }
    fmt.Println("\nFound", len(pows), "such numbers.")
}