This is the easiest one – For Loop from 1 to the specified number. In this article I want to put a pressure on the third point and go through all the methods to achieve factorial function – from the easiest to the most complex. The are several approaches, which can show the experience of the person. And good math skill is very useful in programming. ![]() The factorial function is a very good example for first question on job interview.įirst of all, it is not that hard, but also not that easy. So for example if You want to calculate factorial function of 5 ( 5!), You need to calculate this operation: 5! = 5 * 4 * 3 * 2 * 1 = 120 Interview In short – the factorial function (symbol: !) says to multiply all whole numbers from our chosen number down to 1.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |