maple_learner

10 Reputation

One Badge

1 years, 141 days

MaplePrimes Activity


These are questions asked by maple_learner

THE ISSUE: It's returning a list of [1] when it should be returning [1,1,1,7]

##Find remainder##
rm := proc(a, b) local n; n := 0; while 0 <= b - n*a do n := n + 1; end do; b - (n - 1)*a; end proc;
rm := proc (a, b) local n; n := 0; while 0 <= b-n*a do n := n+1 

   end do; b-(n-1)*a end proc


rm(8, 3657);
                               1

rm(16, 12345);
                               9

##FINDING THE WHOLE NUMBER PORTION ##
whole := proc(a, b) local r, i; r := 0; i := 0; if a < b then r := rm(a, b); i := (b - r)/a; else 0; end if; end proc;
whole := proc (a, b) local r, i; r := 0; i := 0; if a < b then 

   r := rm(a, b); i := (b-r)/a else 0 end if end proc


whole(8, 3657);
                              457

whole(16, 12345);
                              771

 


j = whole(8, 3657);
                            j = 457

k = rm(8, 3657);
                             k = 1

L := [];
                            L := []

L := [op(L), rm(8, 8657)];
                            L := [1]

j = whole(8, 457);
                             j = 57


##GETTING THE LIST OF DIGITS (BEFORE REVERSING)##
HELPER := proc(a, b, L) local j; j := whole(a, b); [op(L), rm(a, b)]; if 0 < j then HELPER(a, j, L); else ; end if; L; end proc;
HELPER := proc (a, b, L) local j; j := whole(a, b); [op(L), 

   rm(a, b)]; if 0 < j then HELPER(a, j, L) else  end if; L end 

   proc


CNS := proc(a, b) HELPER(a, b, L); end proc;
          CNS := proc (a, b) HELPER(a, b, L) end proc

 

CNS(8, 3657);
                              [1]

 

HELPER(8, 3657, L);
                              [1]

 

Page 1 of 1