1. ## Long Division

Write a program to output long division of two integers.
Extra points for multiple bases.
Example run:
Code:
```> longdiv 12345 21

587
------
21 )12345
105
---
184
168
---
165
147
---
18```

2. No, that's not how it works sorry.
You post the code you have so far, and tell us what bit you're having trouble with.

3. So far I have:-

Code:
```main(){

}```
Anyone got any ideas?

it should be
Code:
```int main(void)
{
}```

5. If you're in need of a starting point, then check out CRC algorithms by googling etc. They're really nothing more than long division in disguise.

6. Originally Posted by iMalc
No, that's not how it works sorry.
You post the code you have so far, and tell us what bit you're having trouble with.
Sorry, I didn't make myself clear.
I'm not a student and it's not a homework problem.
It's a challenge.
Here's a starting point:
Code:
```void longdiv( char* sDividend, char* sDivisor ) { /* sDividend / sDivisor */
}

int main( int argc, char** argv ) {
if (argc < 3) return 1;
longdiv( argv[ 1 ], argv[ 2 ]);
}```

7. Well I am able to look at that problem description and know how to do it, so I'm not going to bother. Afterall, I had to work it out for base 2 once.

8. I saw another post suggesting a different challenge and also a post on roman numerals, but they could have been in a different forum.
So I kind of "made up" the long division one. I didn't realize it was a standard programming puzzle. It just seemed funny to me to make the computer do long division! The binary idea sounds good. I'll try it that way. Thanks.

9. It's not so much a common programming puzzle, as it's a common necessity for any big-integer number class, whether you implement it as a string or in binary.

Anyway, sorry about my earlier response. It seems obvious now that you really were just posting a puzzle, rather than posting your own homework, and later pretending it was a puzzle for others. People often do that you see.

The binary division case is actually particularly easy because you can eliminate any traces of multiplication from the function since things either get multiplied by zero or one. But yeah it is worth playing around to implment the version that works on various bases (2 to 10 say).

10. Originally Posted by iMalc
...posting your own homework, and later pretending it was a puzzle for others. People often do that you see.
No problem. I've seen quite a bit of that now that I've browsed around
a little more. I would mention to people asking for help that they should
generally put a little more effort into wording their questions if they
expect others to put in the effort to answer them.

Originally Posted by iMalc
... it's a common necessity for any big-integer number class ... But yeah it is worth playing around to implment the version that works on various bases (2 to 10 say).
I see what you mean about big numbers. I hadn't realized the connection,
but now that you mention it I can see the pattern of a general solution,
a much cleaner pattern than I had conceived.