WeixiangYan/CodeTransOcean huggingface dataset:
Task: Numbers divisible by their individual digits, but not by the product of their digits.




Go: package main

import (
    "fmt"
    "rcu"
)

func main() {
    var res []int
    for n := 1; n < 1000; n++ {
        digits := rcu.Digits(n, 10)
        var all = true
        for _, d := range digits {
            if d == 0 || n%d != 0 {
                all = false
                break
            }
        }
        if all {
            prod := 1
            for _, d := range digits {
                prod *= d
            }
            if prod > 0 && n%prod != 0 {
                res = append(res, n)
            }
        }
    }
    fmt.Println("Numbers < 1000 divisible by their digits, but not by the product thereof:")
    for i, n := range res {
        fmt.Printf("%4d", n)
        if (i+1)%9 == 0 {
            fmt.Println()
        }
    }
    fmt.Printf("\n%d such numbers found\n", len(res))
}






COBOL:         IDENTIFICATION DIVISION.
        PROGRAM-ID. DIV-BY-DGTS-BUT-NOT-PROD.
        
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 CALCULATION.
           02 N             PIC 9(4).
           02 DGT-PROD      PIC 9(3).
           02 NSTART        PIC 9.
           02 D             PIC 9.
           02 N-INDEXING    REDEFINES N.
              03 DIGIT      PIC 9 OCCURS 4 TIMES.
           02 NDIV          PIC 9(4).
           02 OK            PIC 9.
        01 OUTPUT-FORMAT.
           02 DISP-N        PIC Z(4).
           
        PROCEDURE DIVISION.
        BEGIN.
            PERFORM CHECK VARYING N FROM 1 BY 1 
                    UNTIL N IS EQUAL TO 1000.
            STOP RUN.
            
        CHECK SECTION.
        BEGIN.
            SET NSTART TO 1.
            INSPECT N TALLYING NSTART FOR LEADING '0'.
            
            SET DGT-PROD TO 1.
            PERFORM MUL-DIGIT VARYING D FROM NSTART BY 1
                    UNTIL D IS GREATER THAN 4.
            IF DGT-PROD = 0 GO TO NOPE.
            SET OK TO 1.
            PERFORM CHECK-DIGIT VARYING D FROM NSTART BY 1
                    UNTIL D IS GREATER THAN 4.
            IF OK = 0 GO TO NOPE.
            DIVIDE N BY DGT-PROD GIVING NDIV.
            MULTIPLY DGT-PROD BY NDIV.
            IF NDIV IS EQUAL TO N GO TO NOPE.
            MOVE N TO DISP-N.
            DISPLAY DISP-N.
        MUL-DIGIT.
            IF D IS GREATER THAN 4 GO TO NOPE.
            MULTIPLY DIGIT(D) BY DGT-PROD.
        CHECK-DIGIT.
            IF D IS GREATER THAN 4 GO TO NOPE.
            DIVIDE N BY DIGIT(D) GIVING NDIV.
            MULTIPLY DIGIT(D) BY NDIV.
            IF NDIV IS NOT EQUAL TO N SET OK TO 0.
        NOPE. EXIT.
Task: Base 16 numbers needing a to f




Go: package main

import (
    "fmt"
    "strconv"
    "strings"
)

func main() {
    const nondecimal = "abcdef"
    c := 0
    for i := int64(0); i <= 500; i++ {
        hex := strconv.FormatInt(i, 16)
        if strings.ContainsAny(nondecimal, hex) {
            fmt.Printf("%3d ", i)
            c++
            if c%15 == 0 {
                fmt.Println()
            }
        }
    }
    fmt.Printf("\n\n%d such numbers found.\n", c)
}






COBOL:         IDENTIFICATION DIVISION.
        PROGRAM-ID. BASE-16.
        
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 VARIABLES        COMP.
           02 STRP          PIC 99 VALUE 1.
           02 N             PIC 999.
           02 NTEMP         PIC 999.
           02 N16           PIC 999.
           02 NMOD16        PIC 99.
           02 BASE16-FLAG   PIC 9.
              88 BASE16     VALUE 1.
           02 AMOUNT        PIC 999 VALUE 0.
           
        01 OUTPUT-FORMAT.
           02 LINESTR       PIC X(72).
           02 OUTN          PIC BZZ9.
           
        PROCEDURE DIVISION.
        BEGIN.
            PERFORM NONDEC VARYING N FROM 1 BY 1 
                UNTIL N IS GREATER THAN 500.
            PERFORM DISPLAY-LINE.
            DISPLAY ' '.
            MOVE AMOUNT TO OUTN.
            DISPLAY OUTN ' numbers found.'
            STOP RUN.
        
        NONDEC.
            MOVE N TO NTEMP.
            PERFORM IS-NONDEC.
            IF BASE16
                MOVE N TO OUTN
                STRING OUTN DELIMITED BY SIZE INTO LINESTR
                    WITH POINTER STRP
                ADD 1 TO AMOUNT
                IF STRP IS EQUAL TO 73 PERFORM DISPLAY-LINE.
                        
        DISPLAY-LINE.
            IF STRP IS NOT EQUAL TO 1 DISPLAY LINESTR.
            MOVE 1 TO STRP.
            MOVE ' ' TO LINESTR.
            
        IS-NONDEC.
            IF NTEMP IS EQUAL TO ZERO
                MOVE 0 TO BASE16-FLAG
            ELSE
                DIVIDE NTEMP BY 16 GIVING N16
                COMPUTE NMOD16 = NTEMP - N16 * 16
                IF NMOD16 IS NOT LESS THAN 10
                    MOVE 1 TO BASE16-FLAG
                ELSE
                    MOVE N16 TO NTEMP
                    GO TO IS-NONDEC.
Task: Address of a variable




Go: package main

import (
	"fmt"
	"unsafe"
)

func main() {
	myVar := 3.14
	myPointer := &myVar
	fmt.Println("Address:", myPointer, &myVar)
	fmt.Printf("Address: %p %p\n", myPointer, &myVar)

	var addr64 int64
	var addr32 int32
	ptr := unsafe.Pointer(myPointer)
	if unsafe.Sizeof(ptr) <= unsafe.Sizeof(addr64) {
		addr64 = int64(uintptr(ptr))
		fmt.Printf("Pointer stored in   int64: %#016x\n", addr64)
	}
	if unsafe.Sizeof(ptr) <= unsafe.Sizeof(addr32) {
		
		addr32 = int32(uintptr(ptr))
		fmt.Printf("Pointer stored in   int32: %#08x\n", addr32)
	}
	addr := uintptr(ptr)
	fmt.Printf("Pointer stored in uintptr: %#08x\n", addr)

	fmt.Println("value as float:", myVar)
	i := (*int32)(unsafe.Pointer(&myVar))
	fmt.Printf("value as int32: %#08x\n", *i)
}






COBOL: data division.
working-storage section.
01 ptr usage pointer.
01 var pic x(64).

procedure division.
set ptr to address of var.
Task: Fixed length records




Go: package main

import (
    "fmt"
    "log"
    "os"
    "os/exec"
)

func reverseBytes(bytes []byte) {
    for i, j := 0, len(bytes)-1; i < j; i, j = i+1, j-1 {
        bytes[i], bytes[j] = bytes[j], bytes[i]
    }
}

func check(err error) {
    if err != nil {
        log.Fatal(err)
    }
}

func main() {
    in, err := os.Open("infile.dat")
    check(err)
    defer in.Close()

    out, err := os.Create("outfile.dat")
    check(err)

    record := make([]byte, 80)
    empty := make([]byte, 80)
    for {
        n, err := in.Read(record)
        if err != nil {
            if n == 0 {
                break 
            } else {
                out.Close()
                log.Fatal(err)
            }
        }
        reverseBytes(record)
        out.Write(record)
        copy(record, empty)
    }
    out.Close()

    
    
    cmd := exec.Command("dd", "if=outfile.dat", "cbs=80", "conv=unblock")
    bytes, err := cmd.Output()
    check(err)
    fmt.Println(string(bytes))
}






COBOL:       
      
      
       identification division.
       program-id. lrecl80.

       environment division.
       configuration section.
       repository.
           function all intrinsic.

       input-output section.
       file-control.
           select infile
               assign to infile-name
               organization is sequential
               file status is infile-status
           .
           select outfile
               assign to outfile-name
               organization is sequential
               file status is outfile-status
           .

       data division.
       file section.
       fd infile.
           01 input-text pic x(80).

       fd outfile.
           01 output-text pic x(80).

       working-storage section.
       01 infile-name.
          05 value "infile.dat".
       01 infile-status pic xx.
          88 ok-input value '00'.
          88 eof-input value '10'.

       01 outfile-name.
          05 value "outfile.dat".
       01 outfile-status pic xx.
          88 ok-output value '00'.

       procedure division.

       open input infile
       if not ok-input then
           display "error opening input " infile-name upon syserr
           goback
       end-if

       open output outfile
       if not ok-output
           display "error opening output " outfile-name upon syserr
           goback
       end-if

      
       read infile
       perform until not ok-input
           move function reverse(input-text) to output-text

           write output-text
           if not ok-output then
               display "error writing: " output-text upon syserr
           end-if
           read infile
       end-perform

       close infile outfile

      
       open input outfile
       if not ok-output then
           display "error opening input " outfile-name upon syserr
           goback
       end-if

       read outfile
       perform until not ok-output
           display function trim(output-text trailing)
           read outfile
       end-perform

       close outfile

       goback.
       end program lrecl80.
Task: Find words which contains all the vowels




Go: package main

import (
    "bytes"
    "fmt"
    "io/ioutil"
    "log"
    "unicode/utf8"
)

func main() {
    wordList := "unixdict.txt"
    b, err := ioutil.ReadFile(wordList)
    if err != nil {
        log.Fatal("Error reading file")
    }
    bwords := bytes.Fields(b)
    var words []string
    for _, bword := range bwords {
        s := string(bword)
        if utf8.RuneCountInString(s) > 10 {
            words = append(words, s)
        }
    }
    count := 0
    fmt.Println("Words which contain all 5 vowels once in", wordList, "\b:\n")
    for _, word := range words {
        ca, ce, ci, co, cu := 0, 0, 0, 0, 0
        for _, r := range word {
            switch r {
            case 'a':
                ca++
            case 'e':
                ce++
            case 'i':
                ci++
            case 'o':
                co++
            case 'u':
                cu++
            }
        }
        if ca == 1 && ce == 1 && ci == 1 && co == 1 && cu == 1 {
            count++
            fmt.Printf("%2d: %s\n", count, word)
        }
    }
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. ALL-VOWELS.
       
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT DICT ASSIGN TO DISK
           ORGANIZATION LINE SEQUENTIAL.
           
       DATA DIVISION.
       FILE SECTION.
       FD DICT 
           LABEL RECORD STANDARD
           VALUE OF FILE-ID IS "unixdict.txt".
       01 WORD            PIC X(64).
       
       WORKING-STORAGE SECTION.
       01 A               PIC 99.
       01 E               PIC 99.
       01 I               PIC 99.
       01 O               PIC 99.
       01 U               PIC 99.
       01 LEN             PIC 99.
       
       PROCEDURE DIVISION.
       BEGIN.
           OPEN INPUT DICT.
           
       READ-WORD.
           READ DICT, AT END CLOSE DICT, STOP RUN.
           PERFORM CHECK-WORD.
           GO TO READ-WORD.
           
       CHECK-WORD.
           MOVE ZERO TO LEN, A, E, I, O, U.
           INSPECT WORD TALLYING LEN FOR CHARACTERS 
               BEFORE INITIAL SPACE.
           INSPECT WORD TALLYING A FOR ALL 'a'.
           INSPECT WORD TALLYING E FOR ALL 'e'.
           INSPECT WORD TALLYING I FOR ALL 'i'.
           INSPECT WORD TALLYING O FOR ALL 'o'.
           INSPECT WORD TALLYING U FOR ALL 'u'.
           IF LEN IS GREATER THAN 10
              AND 1 IS EQUAL TO A AND E AND I AND O AND U,
               DISPLAY WORD.
Task: Loops_Infinite




Go: package main

import "fmt"

func main() {
	for {
		fmt.Printf("SPAM\n")
	}
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Spam.

       PROCEDURE DIVISION.
           PERFORM UNTIL 1 <> 1
               DISPLAY "SPAM"
           END-PERFORM

           GOBACK
           .
Task: Function definition




Go: func multiply(a, b float64) float64 {
   return a * b
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. myTest.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  x   PIC 9(3) VALUE 3.
       01  y   PIC 9(3) VALUE 2.
       01  z   PIC 9(9).
       PROCEDURE DIVISION.
           CALL "myMultiply" USING 
               BY CONTENT x, BY CONTENT y, 
               BY REFERENCE z.
           DISPLAY z.
           STOP RUN.
       END PROGRAM myTest.

       IDENTIFICATION DIVISION.
       PROGRAM-ID. myMultiply.
       DATA DIVISION.
       LINKAGE SECTION.
       01  x   PIC 9(3).
       01  y   PIC 9(3).
       01  z   PIC 9(9).
       PROCEDURE DIVISION USING x, y, z.
           MULTIPLY x BY y GIVING z.
           EXIT PROGRAM.
       END PROGRAM myMultiply.
Task: Terminal control_Dimensions




Go: package main

import (
    "fmt"
    "os"

    "golang.org/x/crypto/ssh/terminal"
)

func main() {
    w, h, err := terminal.GetSize(int(os.Stdout.Fd()))
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(h, w)
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. terminal-dimensions.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  num-lines PIC 9(3).
       01  num-cols  PIC 9(3).

       SCREEN SECTION.
       01  display-screen.
           03  LINE 01 COL 01 PIC 9(3) FROM num-lines.
           03  LINE 01 COL 05 VALUE "rows by " .
           03  LINE 01 COL 13 PIC 9(3) FROM num-cols.
           03  LINE 01 COL 16 VALUE " columns.".

       PROCEDURE DIVISION.
           ACCEPT num-lines FROM LINES
           ACCEPT num-cols FROM COLUMNS

           DISPLAY display-screen

      *    This pauses the program, as ncurses will immediately revert
      *    back to the console when the program ends.
           CALL "C$SLEEP" USING BY CONTENT 3

           GOBACK
           .
Task: Sum of the digits of n is substring of n




Go: package main

import (
    "fmt"
    "rcu"
    "strings"
)

func main() {
    var numbers []int
    for n := 0; n < 1000; n++ {
        ns := fmt.Sprintf("%d", n)
        ds := fmt.Sprintf("%d", rcu.DigitSum(n, 10))
        if strings.Contains(ns, ds) {
            numbers = append(numbers, n)
        }
    }
    fmt.Println("Numbers under 1,000 whose sum of digits is a substring of themselves:")
    rcu.PrintTable(numbers, 8, 3, false)
    fmt.Println()
    fmt.Println(len(numbers), "such numbers found.")
}






COBOL:         IDENTIFICATION DIVISION.
        PROGRAM-ID. SUM-SUBSTRING.
            
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 CALCULATION.
           02 N         PIC 9999.
           02 X         PIC 9.
           02 DSUM      PIC 99.
           02 N-DIGITS  REDEFINES N.
              03 ND     PIC 9 OCCURS 4 TIMES.
           02 S-DIGITS  REDEFINES DSUM.
              03 SUMD   PIC 9 OCCURS 2 TIMES.
        01 OUTPUT-FORMAT.
           02 N-OUT     PIC ZZZ9.
        
        PROCEDURE DIVISION.
        BEGIN.
            PERFORM TESTNUMBER VARYING N FROM 0 BY 1
                    UNTIL N IS EQUAL TO 1000.
            STOP RUN.
        
        TESTNUMBER SECTION.
        BEGIN.
            PERFORM SUM-DIGITS.
            SET X TO 1.
            IF DSUM IS LESS THAN 10 GO TO ONE-DIGIT-CHECK.
        
        TWO-DIGIT-CHECK.
            IF X IS GREATER THAN 3 GO TO DONE.
            IF ND(X) = SUMD(1) AND ND(X + 1) = SUMD(2) GO TO SHOW.
            ADD 1 TO X.
            GO TO TWO-DIGIT-CHECK.
            
        ONE-DIGIT-CHECK.
            IF X IS GREATER THAN 4 GO TO DONE.
            IF ND(X) = SUMD(2) GO TO SHOW.
            ADD 1 TO X.
            GO TO ONE-DIGIT-CHECK.
        
        SHOW.
            MOVE N TO N-OUT.
            DISPLAY N-OUT.
        DONE. EXIT.
        
        SUM-DIGITS SECTION.
        BEGIN.
            SET DSUM TO 0.
            SET X TO 1.
        LOOP.    
            ADD ND(X) TO DSUM.
            ADD 1 TO X.
            IF X IS LESS THAN 5 GO TO LOOP.
Task: Create a file on magnetic tape




Go: package main

import (
        "archive/tar"
        "compress/gzip"
        "flag"
        "io"
        "log"
        "os"
        "time"
)

func main() {
        filename := flag.String("file", "TAPE.FILE", "filename within TAR")
        data := flag.String("data", "", "data for file")
        outfile := flag.String("out", "", "output file or device (e.g. /dev/tape)")
        gzipFlag := flag.Bool("gzip", false, "use gzip compression")
        flag.Parse()

        var w io.Writer = os.Stdout
        if *outfile != "" {
                f, err := os.Create(*outfile)
                if err != nil {
                        log.Fatalf("opening/creating %q: %v", *outfile, err)
                }
                defer f.Close()
                w = f
        }

        if *gzipFlag {
                zw := gzip.NewWriter(w)
                defer zw.Close()
                w = zw
        }

        tw := tar.NewWriter(w)
        defer tw.Close()
        w = tw
        tw.WriteHeader(&tar.Header{
                Name:     *filename,
                Mode:     0660,
                Size:     int64(len(*data)),
                ModTime:  time.Now(),
                Typeflag: tar.TypeReg,
                Uname:    "guest",
                Gname:    "guest",
        })

        _, err := w.Write([]byte(*data))
        if err != nil {
                log.Fatal("writing data:", err)
        }
}






COBOL:        >>SOURCE FORMAT IS FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. MAKE-TAPE-FILE.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT TAPE-FILE
        ASSIGN "./TAPE.FILE"
        ORGANIZATION IS LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD TAPE-FILE.
01 TAPE-FILE-RECORD PIC X(51).

PROCEDURE DIVISION.
    OPEN OUTPUT SHARING WITH ALL OTHER TAPE-FILE
    WRITE TAPE-FILE-RECORD 
        FROM "COBOL treats tape files and text files identically."
    END-WRITE
    STOP RUN.
Task: Recaman's sequence




Go: package main

import "fmt"

func main() {
    a := []int{0}
    used := make(map[int]bool, 1001)
    used[0] = true
    used1000 := make(map[int]bool, 1001)
    used1000[0] = true
    for n, foundDup := 1, false; n <= 15 || !foundDup || len(used1000) < 1001; n++ {
        next := a[n-1] - n
        if next < 1 || used[next] {
            next += 2 * n
        }
        alreadyUsed := used[next]
        a = append(a, next)

        if !alreadyUsed {
            used[next] = true
            if next >= 0 && next <= 1000 {
                used1000[next] = true
            }
        }

        if n == 14 {
            fmt.Println("The first 15 terms of the Recaman's sequence are:", a)
        }

        if !foundDup && alreadyUsed {
            fmt.Printf("The first duplicated term is a[%d] = %d\n", n, next)
            foundDup = true
        }

        if len(used1000) == 1001 {
            fmt.Printf("Terms up to a[%d] are needed to generate 0 to 1000\n", n)
        }
    }
}






COBOL:         IDENTIFICATION DIVISION.
        PROGRAM-ID. RECAMAN.
        
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 RECAMAN-SEQUENCE COMP.
           02 A     PIC 999 OCCURS 99 TIMES INDEXED BY I.
           02 N     PIC 999 VALUE 0.
           
        01 VARIABLES COMP.
           02 ADDC  PIC S999.
           02 SUBC  PIC S999.
           02 SPTR  PIC 99 VALUE 1.
           
        01 OUTPUT-FORMAT.
           02 OUTI  PIC Z9.
           02 OUTN  PIC BZ9.
           02 OUTS  PIC X(79).
           
        PROCEDURE DIVISION.
        BEGIN.
            PERFORM GENERATE-NEXT-ITEM 15 TIMES.
            PERFORM COLLATE-ITEM VARYING I FROM 1 BY 1
                UNTIL I IS GREATER THAN 15.
            DISPLAY 'First 15 items:' OUTS.
        
        FIND-REPEATING.
            PERFORM GENERATE-NEXT-ITEM.
            SET I TO 1.
            SEARCH A VARYING I
                WHEN I IS NOT LESS THAN N 
                    NEXT SENTENCE
                WHEN A(I) IS EQUAL TO A(N)
                    SUBTRACT 1 FROM N GIVING OUTI
                    MOVE A(N) TO OUTN
                    DISPLAY 'First repeated item: A(' OUTI ') =' OUTN
                    STOP RUN.
            GO TO FIND-REPEATING.
        
        GENERATE-NEXT-ITEM.
            IF N IS EQUAL TO ZERO
                MOVE ZERO TO A(1)
            ELSE
                ADD N, A(N) GIVING ADDC
                SUBTRACT N FROM A(N) GIVING SUBC
                IF SUBC IS NOT GREATER THAN ZERO
                    MOVE ADDC TO A(N + 1)
                ELSE
                    SET I TO 1
                    SEARCH A VARYING I
                        WHEN I IS NOT LESS THAN N
                            MOVE SUBC TO A(N + 1)
                        WHEN A(I) IS EQUAL TO SUBC
                            MOVE ADDC TO A(N + 1).
            ADD 1 TO N.
            
        COLLATE-ITEM.
            MOVE A(I) TO OUTN.
            STRING OUTN DELIMITED BY SIZE INTO OUTS WITH POINTER SPTR.
Task: Tau function




Go: package main

import "fmt"

func countDivisors(n int) int {
    count := 0
    i := 1
    k := 2
    if n%2 == 0 {
        k = 1
    }
    for i*i <= n {
        if n%i == 0 {
            count++
            j := n / i
            if j != i {
                count++
            }
        }
        i += k
    }
    return count
}

func main() {
    fmt.Println("The tau functions for the first 100 positive integers are:")
    for i := 1; i <= 100; i++ {
        fmt.Printf("%2d  ", countDivisors(i))
        if i%20 == 0 {
            fmt.Println()
        }
    }
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. TAU-FUNCTION.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 TAU-VARS.
          03 TOTAL              PIC 999.
          03 N                  PIC 999.
          03 FILLER             REDEFINES N.
             05 FILLER          PIC 99.
             05 FILLER          PIC 9.
                88 N-EVEN       VALUES 0, 2, 4, 6, 8.
          03 P                  PIC 999.
          03 P-SQUARED          PIC 999.
          03 N-DIV-P            PIC 999V999.
          03 FILLER             REDEFINES N-DIV-P.
             05 NEXT-N          PIC 999.
             05 FILLER          PIC 999.
                88 DIVISIBLE    VALUE ZERO.
          03 F-COUNT            PIC 999.
       01 CONTROL-VARS.
          03 I                  PIC 999.
       01 OUT-VARS.
          03 OUT-ITM            PIC ZZ9.
          03 OUT-STR            PIC X(80) VALUE SPACES.
          03 OUT-PTR            PIC 99 VALUE 1.

       PROCEDURE DIVISION.
       BEGIN.
           PERFORM SHOW-TAU VARYING I FROM 1 BY 1
               UNTIL I IS GREATER THAN 100.
           STOP RUN.
       
       SHOW-TAU.
           MOVE I TO N.
           PERFORM TAU.
           MOVE TOTAL TO OUT-ITM.
           STRING OUT-ITM DELIMITED BY SIZE INTO OUT-STR
               WITH POINTER OUT-PTR.
           IF OUT-PTR IS EQUAL TO 61,
               DISPLAY OUT-STR,
               MOVE 1 TO OUT-PTR.

       TAU.
           MOVE 1 TO TOTAL.
           PERFORM POWER-OF-2 UNTIL NOT N-EVEN.
           MOVE ZERO TO P-SQUARED.
           PERFORM ODD-FACTOR THRU ODD-FACTOR-LOOP
               VARYING P FROM 3 BY 2
               UNTIL P-SQUARED IS GREATER THAN N.
           IF N IS GREATER THAN 1,
               MULTIPLY 2 BY TOTAL.
       POWER-OF-2.
           ADD 1 TO TOTAL.
           DIVIDE 2 INTO N.
       ODD-FACTOR.
           MULTIPLY P BY P GIVING P-SQUARED.
           MOVE 1 TO F-COUNT.
       ODD-FACTOR-LOOP.
           DIVIDE N BY P GIVING N-DIV-P.
           IF DIVISIBLE,
               MOVE NEXT-N TO N,
               ADD 1 TO F-COUNT,
               GO TO ODD-FACTOR-LOOP.
           MULTIPLY F-COUNT BY TOTAL.