
Hans Peterson wrote:I'm not sure in which Forum to post this question so I put it in Java in General.
The first (repeat) loop goes (in principle) n/log_2(n) times only that the rest in the division doesn't matter.
So I'm looking here for a mathematical way to display only positiv integer. Maybe with the modulo function?
The for loop runs exactly a times and therefore (imagine the result of the division is a positiv integer) has 2* n/log_2(n) calls.
For z I get the value z = n*(2j+1) because in the first step j=0 and z is n since z= 0 +0 +n = (j+1)*n.
It doesn't. a = 2^log₂(n)
Hans Peterson wrote:a will allways be a multiple of 2.
Thats why I thought I'm not interested in the decimals when I calculate log_2(n).
the second loop runs in Θ(n)
No, afraid not. I have never seen a LaTeX mode on any website. Stephan was using the code button.Hans Peterson wrote:. . . Is there a Latex mode or something . . .
Hans Peterson wrote:Why isn't the loop running n^2 times? Still I don't quite understand why it runs n^2 times but I tested it until n = 5 and the result always was n^2 times
There are three kinds of actuaries: those who can count, and those who can't.
It is sorta covered in the JavaRanch Style Guide. 