Function for Factorial in Python

Easiest way is to use math.factorial (available in Python 2.6 and above): If you want/have to write it yourself, you can use an iterative approach: or a recursive approach: Note that the factorial function is only defined for positive integers so you should also check that n >= 0 and that isinstance(n, int). If it’s not, raise a ValueError or a TypeError respectively. math.factorial will take care of this for … Read more

What is localhost 3000?

To make you understand this you should understand that you need a web server to host the application to run on the web. Then it will be available for most of the people. But that application needs to be developed somewhere. In this case you need a local server. There are several local server instances … Read more

Undo a Git merge that hasn’t been pushed yet

With git reflog check which commit is one prior the merge (git reflog will be a better option than git log). Then you can reset it using: There’s also another way: It will get you back 1 commit. Be aware that any modified and uncommitted/unstashed files will be reset to their unmodified state. To keep them either stash changes … Read more

List of All Locales and Their Short Codes?

The importance of locales is that your environment/os can provide formatting functionality for all installed locales even if you don’t know about them when you write your application. My Windows 7 system has 211 locales installed (listed below), so you wouldn’t likely write any custom code or translation specific to this many locales. Edit: The … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)