Here are the source codes for the paper  "Gaps Between Integers Having a Common Divisor with an Odd Semi-prime"


 

gg := proc (x, y) return abs(x-y)-1 end proc

proc (x, y) return abs(x-y)-1 end proc

(1)

CopyArrayElem := proc (x, n) local y, i; y := Array(1 .. n); for i to n do y(i) := x(i) end do; return y end proc

proc (x, n) local y, i; y := Array(1 .. n); for i to n do y(i) := x(i) end do; return y end proc

(2)

PrintArray := proc (x, n) local i; for i to n do printf("%d, ", x(i)); if i = (1/2)*n then printf("|,") end if end do; printf("\n") end proc

proc (x, n) local i; for i to n do printf("%d, ", x(i)); if i = (1/2)*n then printf("|,") end if end do; printf("
") end proc

(3)

GapArray := proc (x, n) local i, y; y := Array(1 .. n-1); for i to n-1 do y(i) := gg(x(i), x(i+1)) end do; return y end proc

proc (x, n) local i, y; y := Array(1 .. n-1); for i to n-1 do y(i) := gg(x(i), x(i+1)) end do; return y end proc

(4)

ShiftArrayElem := proc (x, n, d) local i, y; y := Array(1 .. n); for i to n do y(i) := x(i)+d end do; return y end proc

proc (x, n, d) local i, y; y := Array(1 .. n); for i to n do y(i) := x(i)+d end do; return y end proc

(5)

NULL

"chost:=proc(p,q) local i,j,m; local Hpq,hh;   Hpq:=Array(1..p+q-2);  hh:=Array(1..p+q-2);    for i from 1 to q-1 do   Hpq(i):=i*p;   od;      for j from 1 to p-1 do;   Hpq(i++):=j*q;   od;   hh:=sort(Hpq);    return hh;    end proc "

proc (p, q) local i, j, m, Hpq, hh; Hpq := Array(1 .. p+q-2); hh := Array(1 .. p+q-2); for i to q-1 do Hpq(i) := i*p end do; for j to p-1 do Hpq(`++`(i)) := j*q end do; hh := sort(Hpq); return hh end proc

(6)

nGroup := proc (p, m) local j, n, ar; ar := Array(1 .. m); for j from 0 to m-1 do n := ceil((j+1)*p/m)-floor(j*p/m)-1; ar(j+1) := n end do; return ar end proc

proc (p, m) local j, n, ar; ar := Array(1 .. m); for j from 0 to m-1 do n := ceil((j+1)*p/m)-floor(j*p/m)-1; ar(j+1) := n end do; return ar end proc

(7)

Position := proc (ary, k) local i, pos; pos := 0; for i to k-1 do pos := pos+ary(i) end do; pos := pos+1; return pos end proc

proc (ary, k) local i, pos; pos := 0; for i to k-1 do pos := pos+ary(i) end do; pos := pos+1; return pos end proc

(8)

groups := proc (p, q, lm, m) local k, j, x, r, ll, rr, ni, bl, br, i; i := 1; printf("______\n"); for k from 0 to m-2 do ll := floor(k*p/m); rr := floor((k+1)*p/m); ni := rr-ll; for j to ni do r := (j+ll)*m-k*p; printf("(%d: %d),", i, r); if j = ni then printf(" # %d p-hosts after q-host %d\n", lm+1, i*q) end if; i := i+1 end do; printf("\n") end do; ll := floor((m-1)*p/m); rr := p-1; ni := rr-ll; for j to ni do r := (j+ll)*m-k*p; printf("(%d: %d),", i, r); i := i+1 end do; printf("\n______\n") end proc

proc (p, q, lm, m) local k, j, x, r, ll, rr, ni, bl, br, i; i := 1; printf("______
"); for k from 0 to m-2 do ll := floor(k*p/m); rr := floor((k+1)*p/m); ni := rr-ll; for j to ni do r := (j+ll)*m-k*p; printf("(%d: %d),", i, r); if j = ni then printf(" # %d p-hosts after q-host %d
", lm+1, i*q) end if; i := i+1 end do; printf("
") end do; ll := floor((m-1)*p/m); rr := p-1; ni := rr-ll; for j to ni do r := (j+ll)*m-k*p; printf("(%d: %d),", i, r); i := i+1 end do; printf("
______
") end proc

(9)

idx := proc (p, m) local i, r, ri; for i to p-1 do r := i*m-floor(i*m/p)*p; if r = 1 or r = p-1 then ri := i end if; printf("%d, ", r) end do; printf("\n"); return ri end proc

proc (p, m) local i, r, ri; for i to p-1 do r := i*m-floor(i*m/p)*p; if r = 1 or r = p-1 then ri := i end if; printf("%d, ", r) end do; printf("
"); return ri end proc

(10)

DoTest := proc (p, q) local k, i, j, x, y, r, ni, lambda, n, g, xx, ll, rr, w, pos, nj, hh, grp; n := p+q-2; g := Array(1 .. n-1); hh := chost(p, q); printf("Hosts of p and q are:\n"); PrintArray(hh, n); lambda := floor(q/p); r := q-lambda*p; printf("Lambda=%d\nr=%d\n", lambda, r); printf("The %d elements in S(r,p) are:\n", p-1); for i to p-1 do printf("%d,", i*r) end do; printf("\n"); printf("The %d elements in rZ(r,p) are:\n", p-1); for j to p-1 do x := j*r-floor(j*r/p)*p; printf("%d,", x) end do; printf("\n"); printf("The %d subsets are as follows:\n", r); groups(p, q, lambda, r); printf("The maximum gap is: %d \n", p-1); g := q-p-1; printf("Total number of maximum gaps is:%d\n", g); g := GapArray(hh, n); xx := CopyArrayElem(hh, n-1); dataplot(xx, g) end proc

proc (p, q) local k, i, j, x, y, r, ni, lambda, n, g, xx, ll, rr, w, pos, nj, hh, grp; n := p+q-2; g := Array(1 .. n-1); hh := chost(p, q); printf("Hosts of p and q are:
"); PrintArray(hh, n); lambda := floor(q/p); r := q-lambda*p; printf("Lambda=%d
r=%d
", lambda, r); printf("The %d elements in S(r,p) are:
", p-1); for i to p-1 do printf("%d,", i*r) end do; printf("
"); printf("The %d elements in rZ(r,p) are:
", p-1); for j to p-1 do x := j*r-floor(j*r/p)*p; printf("%d,", x) end do; printf("
"); printf("The %d subsets are as follows:
", r); groups(p, q, lambda, r); printf("The maximum gap is: %d 
", p-1); g := q-p-1; printf("Total number of maximum gaps is:%d
", g); g := GapArray(hh, n); xx := CopyArrayElem(hh, n-1); dataplot(xx, g) end proc

(11)

``

DoTest(3, 5)

 

DoTest(5, 7)

 

 

 

 

NULL

DoTest(7, 9)

 

DoTest(11, 13)

 

DoTest(7, 11)

 

NULL

DoTest(5, 23)

 

DoTest(11, 47)

 

DoTest(13, 71)

 

DoTest(17, 29)

 

DoTest(23, 31)

 

DoTest(13, 23)

 

DoTest(11, 17)

 

 

DoTest(11, 29)

 

DoTest(13, 27)

 

DoTest(13, 79)

 

DoTest(11, 45)

 

DoTest(41, 71)

 

DoTest(47, 97)

 

DoTest(53, 103)

 

DoTest(101, 199)

 

DoTest(101, 205)

 

DoTest(23, 45)

 

DoTest(13, 25)

 

DoTest(13, 77)

 

DoTest(23, 93)

 

DoTest(23, 91)

 

DoTest(13, 25)

 

DoTest(13, 77)

 

DoTest(47, 91)

 

DoTest(53, 109)

 

NULL


 

Download Hosts.mw


Please Wait...