Question: Proc issues and or some kind of tumor and or brain injury i suspect

Ah yep so i have been trying to arrange this so that it returns the number of iterations required to reach a single digit value but like everything i do this week completely useless 

 


 

 

restart

unprotect(delta):

delta := proc (x, y) options operator, arrow; piecewise(x = y, 1, x <> y, 0) end proc

then the j th summand of the first digital root of 'a' in base 'b'. can be expressed as:

d := proc (a, b, j) options operator, arrow; sum((delta(j, k)-b*delta(j, k+1))*floor(a*b^(k-floor(ln(a)/ln(b))-1)), k = 1 .. floor(ln(a)/ln(b))+1) end proc:

R[0] := proc (a, b) options operator, arrow; sum(sum((delta(m, k)-b*delta(m, k+1))*floor(a*b^(k-floor(ln(a)/ln(b))-1)), k = 1 .. floor(ln(a)/ln(b))+1), m = 1 .. floor(ln(a)/ln(b))+1) end proc

proc (a, b) options operator, arrow; sum(sum((delta(m, k)-b*delta(m, k+1))*floor(a*b^(k-floor(ln(a)/ln(b))-1)), k = 1 .. floor(ln(a)/ln(b))+1), m = 1 .. floor(ln(a)/ln(b))+1) end proc

(1)

DigitalRoot := proc (a, b, N) options operator, arrow; foldl(R[0], R[0](a, b), seq(b, k = 1 .. N)) end proc

proc (a, b, N) options operator, arrow; foldl(R[0], R[0](a, b), seq(b, k = 1 .. N)) end proc

(2)

MAIN BASIC EXAMPLE

SELECT THE NUMBER:

a := 345346462

345346462

(3)

 

 

SELECT THE NUMBER BASE FOR WHICH YOU WISH TO REPRESENT a:

b := 10

10

(4)

The output will be the digits of the  base b representation of a, (or the coefficients of it's p-adic expansion?):

seq(d(a, b, j), j = 1 .. floor(ln(a)/ln(b))+1)

3, 4, 5, 3, 4, 6, 4, 6, 2

(5)

DigitalRoot(a, b, 0), DigitalRoot(a, b, 1), DigitalRoot(a, b, 2)

37, 10, 1

(6)

n := 0:

37

 

0

(7)

``

``


Sorry EDIT its ok i got it old_garbage_2015002.mw

Download old_garbage_2015.mw

Please Wait...