Rahul Jose me@rahuljose.com

Rahul Jose is a Bangalore based Engineer with a passion for Technology,Startups and Statistics and is currently working on Automotive Embedded Systems

You can contact him at
me[at]rahuljose[dot]com
Dec 05
Permalink

Finding the Number of zeroes in the product of all numbers between 1 and 100

life-src:

rahuljose:

I am sure there is a simpler mathematical solution but this is good enough for now I have always been a brute force guy sadly

#include<stdio.h>
void main()
{
int i;
long double p=1;
for(i=1;i<101;i++)
{
p=p*i;
}
printf("Product of all numbers between 1&100 is %LG \n",p);
}


No Compiler installed no issues head to http://codepad.org/

PS:-

The answer is 152 zeroes.

My takeaway from this is the printf Format placeholder for Long Double-%LG


Actually, there is a better (and more accurate way. Note that your double isn’t large enough to hold a value as large as 100, neither is the unsigned long. But Java does have the BigNumber object that can be used to store numbers larger than you can imagine. What you’d have to do in C is to keep an array to keep track of all those digits and then perform the computation as if you were writing it down on pen and paper, take each thing one-by-one and multiply. I will work on a possible solution to this.

I really screwed this one up should have guessed 152 is way large a number hope this helps someone.100! is definitely a much simpler approach and combined with Wolframalpha the best.What happened here was the answer provided by the program was a approximation of the final result.The data structure is definitely big enough to hold the result no need to fix that.I shall re-post the program with precision later.

PS: The correct result is 24 as pointed out by Manu and Wolframalpha

Dec 04
Permalink
Nov 30
Permalink

:) Great take on Apple’s Advertising Loved it

Nov 25
Permalink

Penguin Cafe Orchestra-Perpetuum mobile

From the Soundtrack of Mary and Max

Links of Interest:-

Penguin Cafe Orchestra

Perpetuum mobile

Nov 24
Permalink
Nov 23
Permalink
Nov 22
Permalink
Nov 18
Permalink

“Run one-eleven”(Part 2)

This is a continuation from here .So the wireless order taking project did not seem to head anywhere and I was having way too much free time for my own good.So I decided to spend the time wisely by obtaining a certification from Oracle since I am terrible at classroom learning,the best plan of action was to obtain the material required for learning and studying for it independently the material wasn’t all new to me I had learnt part of it during my School Days and during Engg. but the PL/SQL part was quite new.Thankfully I cleared the required exams for the Oracle Certified Associate level in one shot,the Oracle Certified Professional level requires one more exam to be taken for which I am currently preparing.Also after being stuck at developing r.emynd.us(which though interesting is pretty much dead I am sad it did not get a chance to be released to the public)for a real long time I am going to change that to “looking for work” with a link to my resume .If you work on anything related to web applications or mobile applications on platforms like the Android,J2ME or iPhone I might be worth a shot you know how to get in touch.

Now coming to the more interesting part I recently came across this vanity card by Chuck Lorre on a recent episode of Big Bang Theory which seemed very apt to me.Read it carefully you will be seeing quite a bit of it here.I admit it maintaining a blog with a post a day is a real daunting task,coming up with things that will interest and hold that interest is hard very hard..

Nov 14
Permalink
Nov 13
Permalink
Hmm..

Hmm..