# Maple program. Task: Generate an OEIS b-file of highly composite numbers on standard # output from A. Flammenkamp's HCN file. # Provision: the file HCNs (gunzipped, in pure ASCII form) # is in the current working directory of this Maple program, as taken # from http://wwwhomes.uni-bielefeld.de/achim/highly.html . # usage: # maple -q A002182.mp > b002182.txt # where the A002182.mp is this file here, and the name of the redirected # output a standard of the OEIS http://research.att.com/~njas/sequences/ . # R. J. Mathar, 2007-11-26, http://www.strw.leidenuniv.nl/progs/A002182.mp fHCN := fopen("HCNs",READ) : # The offset is 1 n := 1: # optional upper number of lines in the b-file (standard output) nmax := 20000 : # The outer loop reads a line of "HCN" until the file is exhausted # or the nmax limit is reached. bfil := readline(fHCN) : while StringTools[WordCount](bfil) > 0 and n < nmax do # Split the line into blank-separated tokens bfil := StringTools[Split](bfil) ; # We ignore the first three numbers (floating point and big omega count) and # loop over the exponents and their optional multiplicities e_i^k_i. # The full product is initialized with 1. a := 1 : p := 2 : for e from 4 to nops(bfil) do # We decompose the e_i and k_i separated by the roof-top # eiki := StringTools[Split](op(e,bfil),"^") ; eiki := sscanf(op(e,bfil),"%d^%d") ; # missing roof top means multiplicity is one if nops(eiki) > 1 then k := op(2,eiki) ; else k := 1 : fi ; while k > 0 do a := a*p^op(1,eiki) ; k := k-1 ; p := nextprime(p) : od: od: # OEIS b-file format: index followed by blank and the HCN printf("%d %d\n",n,a) ; # the next line will refer to the next n-number in the output n := n+1 : # get the next line from the HCNs file bfil := readline(fHCN) ; od: # Because this is an orderly program, we also close the # Flammenkamp file -:) fclose(fHCN) :