1
# pdhi - Pan Digital Halving Index with GNU bc
2
# Returns how many times x must be divided by 2 before
3
# the result contains all digits from 0 to 9 (if ibase = 10).
4
# e.g. 3339 -> 1669.5 -> 834.75 -> 417.375 ->
5
# 208.6875 -> 104.34375 -> 52.171875 ->
6
# 26.0859375 -> 13.04296875, i.e. 8 times
8
# Uses ibase as the base for divisions (usually 10)
11
auto d[],xi,xf,c,r,pdhi,lim,i;
13
c=1;pdhi=-1;lim=int(10/ibase+3)*scale
22
for(i=lim ; i && xf ; i--){
30
for(r=0;r<ibase;r++){c-=d[r];d[r]=0}
36
# pdmi(x, m) - Pan Digital Multiplying Index
37
# Returns how many times x must be multiplied by m before
38
# the result contains all digits from 0 to 9 (if ibase = 10).
39
# e.g. pdmi(3339,0.5) -> 1669.5 -> 834.75 -> 417.375 ->
40
# 208.6875 -> 104.34375 -> 52.171875 ->
41
# 26.0859375 -> 13.04296875, i.e. 8 times
43
# Uses ibase as the base for divisions (usually 10)
46
auto d[],xi,xf,c,r,pdmi,lim,i;
48
c=1;pdmi=-1;lim=int(10/ibase+3)*scale
57
for(i=lim ; i && xf ; i--){
65
for(r=0;r<ibase;r++){c-=d[r];d[r]=0}