|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
FORTRAN
DETAILS
Question: Why doesn't Fortran have intrinsic functions for something as simple as factorial?
Answer: Two reasons. Factorial isn't all that common in heavy duty scientific and engineering applications. When it does occur, it almost always in a context where it is more computationally efficient to generate it as you go. You need 2! first then 3!, then 4!, etc. You are basically stuck doing a factorial within the context of a do loop unless you get really good and learn to write "recursive functions", but then you are just fooling yourself and writing another form of do loop. When you are taking the factorial of a large number and don't need an exact answer you can resort to Stirling's Approximation. A Fortran statement that will load the value of this approximation into the variable nfact is:
|
|
|
Category |
Fortran Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 7353 users |
Added on |
5/15/2014 |
Views |
66947 |
Rate it! |
|
|
Question:
Why doesn't Fortran have intrinsic functions for something as simple as factorial?
Answer:
Two reasons. Factorial isn't all that common in heavy duty scientific and engineering applications. When it does occur, it almost always in a context where it is more computationally efficient to generate it as you go. You need 2! first then 3!, then 4!, etc. You are basically stuck doing a factorial within the context of a do loop unless you get really good and learn to write "recursive functions", but then you are just fooling yourself and writing another form of do loop. When you are taking the factorial of a large number and don't need an exact answer you can resort to Stirling's Approximation. A Fortran statement that will load the value of this approximation into the variable nfact is: Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How do we know where various steps go in a Fortran program?
|
View Answer
|
|
Where can I get a Fortran Compiler for an IBM PC?
|
View Answer
|
|
How do you use a logical variable? What is stored there?
|
View Answer
|
|
What directory is used by the compiler for compiling a Fortran Program? Where does f77 live?
|
View Answer
|
|
Why do you put so many lines of empty space in your programs?
|
View Answer
|
|
Do we need to prompt the user for input on our programs?
|
View Answer
|
|
Do we need to prompt the user for input on our programs?
|
View Answer
|
|
Can you give us a complete list of the Fortran commands and what they do?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Fortran Interview Questions & Answers - Exam Mode /
Learning Mode
|