Use the maximun processing power to calculate the factorial of 80,000. How?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It is because those library is already installed on FC4.
But when I compile the code, it report the undefined reference error.
It seem that all the function start with mpz is not defined.
Do I have to remove my already installed lib with those you give?
Just leave the installed lib as it is now.
The reason mpz.. functions are not defined is because the compiler cannot find the "gmp.h" header file.
Distribution: Gentoo (desktop), Arch linux (laptop)
Posts: 728
Original Poster
Rep:
Quote:
The reason mpz.. functions are not defined is because the compiler cannot find the "gmp.h" header file.
Most likely you still need to install the gmp-devel-4.1.4-6.i386.rpm package.
The compiler didn't say that the gmp.h header is not found.
It only said that those mpz* functions are not defined.
The package gmp-devel-4.1.4-6.i386.rpm is already installed.
It is so trange, isn't it?
Distribution: Gentoo (desktop), Arch linux (laptop)
Posts: 728
Original Poster
Rep:
Thanks alot Hko,
Your code work, it was my fault to make it not working.
And by the way: The number digit is out range of my screen display.
It means some digit cannot be diplayed.
Can you answer that last questions please?
That's correct. The number can get very large (HUGE actually), and don't fit on a screen. Calculate smaller numbers, or redirect the output to a file and look at it with an editor, change the program yourself to make it split the number into lines of 72 characters, or try one of the other solutions mentioned in this discussion to print something like "1.34587982E+7743", or whatever.
There no real "solution" here. There no real "problem" either. Your ask the computer to give you a very big number, and then you get it. It may not fit on the screen, but thats also the case with large bitmap-images, large texts don't fit on one page or one screen.
Distribution: Gentoo (desktop), Arch linux (laptop)
Posts: 728
Original Poster
Rep:
Quote:
Originally Posted by Hko
That's correct. The number can get very large (HUGE actually), and don't fit on a screen. Calculate smaller numbers, or redirect the output to a file and look at it with an editor, change the program yourself to make it split the number into lines of 72 characters, or try one of the other solutions mentioned in this discussion to print something like "1.34587982E+7743", or whatever.
There no real "solution" here. There no real "problem" either. Your ask the computer to give you a very big number, and then you get it. It may not fit on the screen, but thats also the case with large bitmap-images, large texts don't fit on one page or one screen.
I know, I know.
There is no problem.
What I want to ask is like this:
I remeber that there I can redirect the output to a special program, and that program will show the output page by page.
First It will display an amount number of digit which fit the screen.
Then, I have to press Enter key to go to next page.
But I have forget that software's name.
Would you mind showing me it name please.
Thanks anyway.
He pointed out that even calc.exe, a small calculator software in windoze can calculate the factorial of 80,000 within a few seconds.
But this number is out of range in any linux calculator software.
I was so angry to hear that.
don't get mad, get even
I tried this with 120,000, calc couldn't, plus it's a bit more accurate!!
Code:
(defun fac(n)
(let ((result 1))
(dotimes (i n)
(setq result (* result (+ i 1))))
result))
(print "Number for factorial:")
(print (fac (print (read))))
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.