Okay, so I have been searching the internet and have found many things related to this question. However, I am not able to put the pieces together in order to figure this out.
The requirements are to calculate a large factorial (e.g. 999!) USING LINKED LISTS and NODES. There are many people online that have shown a basic way of calculating a factorial and I understand how to do the factorial part, but the part I am having trouble with is filling each node with an Int between 0-999 (a three digit number) then printing out each node to look like a whole number (including commas).
How can I achieve this? - My thoughts are to get the result of n! and just do %10, %100,etc.. to break it up and insert the parts into nodes, but that would be pointless because the factorial would have to be completely solved for that to work. So that would be dumb.
The reason for doing this is to learn how to manipulate nodes and linked lists for my Data Structures class.
To me, this a clear explanation, but please let me know if the question is unclear and I will try to explain. Any help will be much appreciated.
(I dont have any code to show besides a basic factorial function that I am using as a bases to build upon).
Okay, I think I understand what you're after.
At the end of this answer is a link to a Gist that solves this problem. I'm not entirely sure it's what you are after, alas... it's my best guess.
The algorithm consists of five steps:
It is inspired by the method described here on math.stackexchange.com. I strongly suggest reading both the question and answer linked before examining the Gist.
Now that that's been said, the Gist can be found here. It is very rough, meant only as a quick demonstration of the method.
I hope it helps you. Best of luck.