Programming This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
|
12-06-2005, 09:25 AM
|
#16
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep:
|
Quote:
Originally Posted by TruongAn
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.
Most likely you still need to install the gmp-devel-4.1.4-6.i386.rpm package.
Last edited by Hko; 12-06-2005 at 09:26 AM.
|
|
|
12-08-2005, 09:49 AM
|
#17
|
Member
Registered: Dec 2004
Location: Vietnam (Việt Nam)
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?
|
|
|
12-08-2005, 12:56 PM
|
#18
|
Member
Registered: Jun 2005
Posts: 542
Rep:
|
Check /usr/local/include
In that case, use -I/usr/local/include in your CFLAGS or your compiler options
|
|
|
12-09-2005, 03:29 AM
|
#19
|
Member
Registered: Dec 2004
Location: Vietnam (Việt Nam)
Distribution: Gentoo (desktop), Arch linux (laptop)
Posts: 728
Original Poster
Rep:
|
The gmp.h file was in /usr/include/
What do I have to do next?
|
|
|
12-09-2005, 12:33 PM
|
#20
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep:
|
I just read a previous post from you. And it seems I didn't read it well enough. Here's the important part of your post again:
Quote:
Originally Posted by TruongAn
But when I compile the code, it report the undefined reference error.
It seem that all the function start with mpz is not defined.
|
The real problem is you did not read my post well enough .
I said in my first post:
Quote:
compile the program below with the "-lgmp" option:
Code:
gcc -Wall -lgmp -o bigfactorial bigfactorial.c
|
Please try again. I'm 99.9% sure it will work this time.
|
|
|
12-10-2005, 06:24 AM
|
#21
|
Member
Registered: Dec 2004
Location: Vietnam (Việt Nam)
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?
|
|
|
12-10-2005, 06:36 AM
|
#22
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep:
|
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.
|
|
|
12-10-2005, 08:00 AM
|
#23
|
Member
Registered: Dec 2004
Location: Vietnam (Việt Nam)
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.
|
|
|
12-10-2005, 08:48 AM
|
#24
|
Senior Member
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537
Rep:
|
less or more can do this.
use a pipe like below.
Code:
user@computer# program | less
|
|
|
12-11-2005, 01:06 AM
|
#25
|
Member
Registered: Dec 2004
Location: Vietnam (Việt Nam)
Distribution: Gentoo (desktop), Arch linux (laptop)
Posts: 728
Original Poster
Rep:
|
Thank you verymuch everyone.
The problem was solve
|
|
|
12-12-2005, 02:44 PM
|
#26
|
Senior Member
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515
|
Quote:
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))))
Code:
$ time clisp fac > 1
120000
real 1m49.34s
Code:
$ more 1
"Number for factorial:"
120000
22406714655797362497993141608227937794745126522360269157176324077266000869524416
96464220700886713641449525104754506023560378296179044316346155136811811432217357
41955507780432562420857764113683442185114999824271813031473057741490222841643455
73022465517944363931741556674593664365451020925194218152905164901433493592952218
22896593728627965151535688281280200878000149352240502842359028527723078015271180
50458242652386480055392185427942264443111473352658235772337855837529324062196695
44961804635095255828795189487438038905479719573148957130771241566906232066944058
93734229095495782383936366268985526763061312511630137955895607801118555279301283
02582633839857393183474754162455367625917538950309047607860827401491584840354533
86890588445418570279640035957924446766558781129816064757023522109478122261799149
36319646597516057671738785692189052754644940134684589731255071881453775930037900
89698428173971970179835309458680797223238533828321293042435303142991457704988917
32163885160960190838520067879936369464778846634588631074297262004259753624715581
74407633514069010282425970048290440051632724760390237868586525757655509050460714
24391613450554566641947835353130527773248423107177154789748768608481271976175249
34007038490462733006644638449034912113693940612519109017526212035377703846304949
44382572686079512843944512798981895808077379963730288784501864113305123012455137
19839121349718128824900968034804336743888885250887589096635288356979185454179343
52085150298782028752230381723828095797255579365127860012002146438324835973423682
42554700556256639240953407684940093678111788722060125730322446644548933689614742
etc etc etc etc etc
3GHz P4 laptop 512MB RAM
(don't tel him you can get clisp for windows though )
Last edited by bigearsbilly; 12-12-2005 at 02:45 PM.
|
|
|
12-12-2005, 03:08 PM
|
#27
|
Senior Member
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515
|
doh
maybe I should have read all the other posts first!
|
|
|
All times are GMT -5. The time now is 11:08 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|