M G Harish

Wednesday, December 03, 2008

Code for Factorial, without Recursion

After having been declared to be an impregnable procrastinator by all my close-circle friends, after being connoted to update it by those who I didn't even know were reading my blog and after being told "Enough is enough, now update it buddy" by a few friends, I am in the same situation as the Indian government after the Mumbai attacks. I have no other go than updating it, at least for the sake of hushing them up till the next terror attack near my house. So here I go...

As you might already be knowing, I prefer calling programming an art to calling it a process. That's the reason I enjoy it.

Coming to the point, my friend cum colleague was trying to write a program for generating Pascal Triangle. I decided to play along and wrote a code. In the process, I wrote a function to calculate factorial for a number in an unusual way, without recursion.

Generally an incremental loop is used from 2 to N. But I used decrementing loop and here is the outcome (Code written in C programming language):

unsigned int fact(unsigned int n)
{
unsigned int f=n;

while(n---2)
f*=n;
return f;
}

Main thing I wanted to convey in this code is the while loop, which uses the unusual "--" & "-" operator pair.

It works similar to this loop:

for(f=n;n>=2;n--)
f=f*n;

Not a great piece of code, but I found it to be a little interesting. Hence the post.

Sunday, September 21, 2008

Reviews - A Wednesday and Rock On!!

I never thought I would be writing a movie review in my blog. But after watching these two movies, Rock On!! and A Wednesday, (particularly the latter) I can't refrain myself from commenting on them. They are so good that you would regret if you don't watch them.

Rock On


Rock On!! is all about a music band called Magik. Four men with a common aim join their hands together to realize their dreams. But, being amiss on a small issue, they depart. How they reunite and how one can lose his felicity is the gist of the story. It reflects everyone's life because of its flash-backs which push everyone to his vernal days.

A wednesday


A wednesday, on the other side, is completely different. No hero, no heroine and no songs. Not a typical bollywood movie at all. However, it catches attention right from first scene to the last with its tight storyline and outstanding acting by every single artist. Naseeruddin Shah steals the show with his natural performance. This terrorism-based story revolves around Naseeruddin Shah, who calls Anupam Kher (police officer) with specific demands. It's a small movie (by bollywood standards, with only a runtime of around 95 minutes) but with a big impact. It reflects the minds of the Indians and despises the corrupted Indian administration system.

I don't want to spoil your interest by telling more about these movies. On a scale of 5, I would provide a rating of 3.5 to Rock On!! and 4.5 to A wednesday.

Tuesday, September 09, 2008

Face Recognition - Ultimate feature of Picasa

A picture speaks thousand words. The internet is becoming full of images. Google seems to have found future in the cutting edge face recognition for the images. It has introduced face recognition for the photos uploaded by the users. If you have not explored this feature, I say, the right time is NOW! I am balled over in the first attempt itself!!

  1. Select New Features at the top right.
  2. Select See name tags in action.
  3. Click Get started with name tags.
  4. Click Try It in the right pane.
  5. Click Start Processing photos.
Wait for some time. Picasa will scan all your photos and index all the faces found. It starts asking you the name of the person in the photos. The best thing is that it selects a bunch of photos, and all of them will be of the same person and its Suggestion is just marvellous. Most of the times, you don't even have to think before selecting the first suggestion. I can't explain the greatness of this feature in words here. Just use it and experience!!

PS: Google has already rolled out a hidden feature of face recognition in its image search. When you search for an image, say Sachin, the url of the image will be something like http://images.google.com/images?q=sachin. You can add &imgtype=face at the end of the URL, i.e., http://images.google.com/images?q=sachin&imgtype=face to find only images containing face.

Friday, July 25, 2008

Serial Bomb Blasts in Bangalore?

Bangalore was considered to be a safe place so far. But with the serial bomb blasts in Madiwala and surrounding places, I doubt it can continue to be so. News is spreading and details are not known.

Saturday, May 24, 2008

Top reason to adopt Firefox

We have been hearing, right from its introduction, that Firefox is the most secure browser. But many of us haven't bothered to know why is is deemed so. I am not going to explain about all those features which make it safer than other browsers, say Internet Explorer. I just thought I would share an experience which happened today, which can be considered to be the top reason to adopt Mozilla Firefox.

I got a mail from an unknown email id, pointing me to a blog. When I clicked that link, it redirected me to another site, http://www.posokei.com and to my surprise, a message popped up from the address bar, with title Suspecting Web Forgery.



It also provided a brief detail about the site and why that site has been classified as a phishing site. This means that the user is made fully aware of the site before he proceeds to browse it. Prevention is better than cure. Is it not be best reason to use firefox?

You can read about phishing protection in Firefox here

Tuesday, May 06, 2008

Google introduces Hindi translation

It has was a long wait, but well deserved. So far we were not able to dynamically translate text to any Indian language. Google has finally done it by introducing translation for Hindi. You can now translate any text or web page from English to Hindi or from Hindi to English. We can expect translation to and from other Indian languages also soon.

Although it is not perfect, I'm sure it will improve quickly. Be sure to improve the translation if you find a better word/sentence when you are using it!

Earlier introduced transliteration tool, which supported dynamic transliteration to Indian languages like Hindi, Kannada, Tamil, Telugu and Malayalam, which reduced the popularity of software based transliteration tools like Baraha.

I hope to see the translation expanded to include other languages also.

Saturday, May 03, 2008

Free Linux or Paid Windows? - Time for a change


Linux or Windows

Ask anyone who has used Linux operating system for a while and you'll receive all but positive responses about Microsoft Windows. Some people even tell that they hate to use Winodws. Why is it so? Are they crazy to think Linux is more user-friendly than Windows? But wait, since they have used both Linux and Windows for long enough to be able to compare them, there must be something true about it, right?

If you want to compare Microsoft Windows Vista and Ubuntu, a flavour of Linux see this video:



See the difference? People who admired the graphics and visualization abilities of Windows Vista when it entered the market, are now blaming it for using huge resources. When Linux can do it in a better way for free with much less system resources, why pay Microsoft for doing it pathetically? Whenever we hear about Linux, we hear that it is more secure, powerful, server-class operating system. Moreover, Linux is completely free. No need of purchasing, applying the key, activating blah-blah. Then why is it not as popular as Windows? The only reason I can think of might be due to its installation, which is not as straight forward as that of Windows. But believe me, it is not very hard to learn. One more thing: as a Vista user, I hereby declare that VISTA SUCKS!

A good news, if you are willing to switch to Linux: Ubuntu gives FREE CDs. No shipping charges also. All you need to do is to register yourself and request for it!