Algorithms



hi
can anyone tell me how the vale is calculated using prob function of ms excel
it is used like this:
PROB
Returns the probability that values in a range are between two limits. If upper_limit is not supplied, returns the probability that values in x_range are equal to lower_limit.
Syntax
PROB(x_range,prob_range,lower_limit,upper_limit)
X_range is the range of numeric values of x with which there are associated probabilities.
Prob_range is a set of probabilities associated with values in x_range.
Lower_limit is the lower bound on the value for which you want a probability.
Upper_limit is the optional upper bound on the value for which you want a probability.
Remarks
If any value in prob_range = 0 or if any value in prob_range > 1, PROB returns the #NUM! error value.
If the sum of the values in prob_range ¹ 1, PROB returns the #NUM! error value.
If upper_limit is omitted, PROB returns the probability of being equal to lower_limit.
If x_range and prob_range contain a different number of data points, PROB returns the #N/A error value





Is it possible to get the rightmost NONZERO digit of a factorial without calculating for it?
Say 1000! = 2
Regards,
Ian
*NO, this is not a homework.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.





I assume you mean without calculating the factorial but some simpler, faster calculation? You can rewrite a factorial as a polynomial in n but I'm not sure if that gives you an easy pattern for the last digit. And by definition, all factorials except 1! and 0! are even. Does this have a practical application or are you just curious?
If you don't have the data, you're just another a**hole with an opinion.





Nope. This is part of the question set my adviser gave me to prepare for a certain competition.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.





Ian Uy wrote: It is said that the most complex structures built by mankind are software systems.
I've heard that bandied about but I think I'll disagree. They usually quote Vista at 50 million lines of code yet the latest generation of processor chips boast over 2 billion transistors. And you could argue that much of what gets counted in an operating system are simply utilities that are applications running on the base system so the core is smaller still.
If you don't have the data, you're just another a**hole with an opinion.





Hi,
I tend to disagree. Hardware, especially CPU design, mainly consists of very repetitive
structures, whereas software, all kinds of it, is very inhomogeneous. And a new CPU gets
designed in a matter of months, a new OS takes several years.
That helps explaining why you would find less than 10 bugs in your CPU having
2 billion transistors, and several thousands of bugs in just 50 million lines of Windows code.
So if you want to compare complexity, I suggest you look at design effort, and number
of bugs.





I still will disagree. In programming we keep using the same structures over and over again but insist on lovingly hand coding them each time. The chip makers have better tools and love to reuse their building blocks. A large part of their reuse is automated which explains the smaller number of bugs. They prove their components and then build up. Programmers make the same mistakes at ever increasing scales.
On another note, humans make machines with millions of parts. I will contend that one line of code is not equivalent to designing one mechanical part in complexity.
If you don't have the data, you're just another a**hole with an opinion.





Ian Uy wrote: Is it possible to get the rightmost NONZERO digit of a factorial without calculating for it?
Yes, for example the last nonzero digit of 1,000,000! is 4.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."





Got it!... after about 10 mins of tinkering...
static int fac_last_digit(int x)
{
int res = x;
int mod = 10;
while (x > 1)
{
if ((res * (x  1)) % mod == 0) mod *= 10;
res = (res * (x)) % mod;
}
return (res / (mod / 10));
}
The trick is to use the % operator with increasing powers of 10 depending on if the result is a multiple of the original modulus value...
(Needs tidying up a little)... why you need this is a mystery though.
Matthew Butler





Nice try, but you will quickly fall over without a large integer class. Even 1000! ends with 249 zeros, so mod will grow to about 10^249 or so.
If you get bored, try to write a routine to compute the last nonzero digit of googol! = (10^100)!, you should get 6.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."







General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.