1

I have to divide any number (no matter the size) by another number using Large Integer Division using Knuth's Algorithm D (The art of programming Volume 2), for example 74839234 by 72548.

I made two arrays to represent these numbers

n[] = {7,4,8,3,9,2,3,4}
d[] = {7,2,5,4,8}

I am trying to get an output like this:

q[] = {1,0,3,1}
r[] = {4,2,2,4,6}

I really don't know where to start with this. Any help or guidance would be appreciated!

3
  • 5
    Write the algorithm you have been instructed to use in english instructions, e.g. how you would tell a human to do it. Identify programming structures like for loops and ifs and whiles in it. Rewrite as pseudocode. Then, rewrite it as code. Commented Apr 18, 2013 at 4:23
  • which programming language ? Commented Apr 18, 2013 at 4:29
  • Im having some issues understanding the algorithm. Because of that i dont know where to start when pseudocode. I have been sitting playing in excel trying to figure it out. Commented Apr 18, 2013 at 4:59

1 Answer 1

1

At D1 you have d=1, so set

n[]={0,7,4,8,3,9,2,3,4}

n = 5, m = 3.

Also, there is a formal error in step D4: (second line) should be ...

minus q(hat) times (v1, v2, ..., vn)b TIMES b ** (m - j).

Here, ** means "power of" (Fortran style for easy writing). Of course, b = 10 here, so

times b ** (m - j) shifts the subtrahend left, to proper place for subtraction.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.