What Does This Function Do?

1. Please, give your answers in comments – what does the function written below do:

a)      recognizes prime numbers

b)      recognizes prime numbers in interval [100;999]

c)      neither a) nor b) is correct

d)      other variant (please, specify)

2. And the second question is – is this function a correct solution if the task is as follows: `Please, write a function that recognizes all the prime numbers consisting of exactly 3 digits`:

a) yes

b) no

The function (in C++):

bool f(int x) {

 for (int y=2;y<x;y++)

  if (x%y==0) return false;

 return true;

}

P.S. I wish all of you wrote your thoughts in order to make a student of mine understand the essence of the thing!

Advertisements

Question of the Day

Have you ever drunk some coffee during the coffee drinking time?

And, what do you know, I couldn’t remember any such occasion..

Published in: on Wednesday, January 23, 2008 at 7:29 pm  Comments (1)  
Tags: , , , , , , ,

Am I a Complete Moron In Using Google?

I guess I just can’t use internet search engines. I guess I have no skills or something. I thought it will be very easy to find some good metamodel for UML ORG (organization) diagrams. Well, I couldn’t.. Does it mean the particular metamodel doesn’t exist? 😀 Anyway, can someone help me find it? Or I’ll be forced to come up with my own ideas of how this metamodel could look like?

Published in: on Thursday, January 17, 2008 at 3:44 pm  Comments (3)  
Tags: , , , , , ,

Music – a Special Form of Mathematics

Music is the pleasure the human mind experiences from counting without being aware that it is counting

/Gottfried Leibniz/

I read it here and I found it to be true!

Published in: on Thursday, January 17, 2008 at 12:03 pm  Comments (2)  
Tags: , , , , , , ,

Random Number Generator – As Easy As 01, 10, 11..

Someone told me it is not a trivial task to make a good function generating a random number. What a fool I was to believe him! It turns out you can write down the function very easily. For example, in C++:

int getRandomNumber() {

   return 3; // proven to be random – obtained by throwing a dice

}

Not too complicated function, eh?

Published in: on Thursday, January 10, 2008 at 6:50 pm  Comments (2)  
Tags: , , , , , , , , ,

Blog Stats Is an Interpolation of What?

When looking at the diagram of `Dashboard à Blog Stats` in my WordPress, I can’t stop wondering about this curve – it must be an interpolation of some function. How could this function look like? What would be other arguments of this function except for the date (what are factors that affect the value of this function)? Can anybody define it precisely? Or not so precisely?

Published in: on Thursday, January 10, 2008 at 2:43 pm  Comments (7)  
Tags: , , , , , , , , , ,

Cite of the Day

All our faith is pinned on Edgars

/Said by my boss on a seminar today/

P.S. Edgars – that’s my name if you are starting to look for a vocabulary, my dear reader.. 😉

Published in: on Tuesday, January 8, 2008 at 5:57 pm  Comments (2)  
Tags: , , , , , ,

I Bought a Car Today!

Oh yes, I did! Indeed! It’s my 3rd car already. After BMW and VW, now all my attention will be paid to my new Renault Megane. I am progressing if you look at the years of my cars – 1986, 1991, 1997.. Not bad, I would say, not bad at all. If the tendency continues, I will bye a car of the year 2004 in some 2009, and then a car of the year 2012 in some 2012 or 2013.. 😉

It’s a party this night! 8)

Published in: on Monday, January 7, 2008 at 7:56 pm  Comments (6)  
Tags: , , , , , , , , ,