Michells Mesterværk

Vinderen af julekalenderens låge 2

by Administrator 4. December 2009 10:39

Mange gode forslag, dog kunne alle ikke svare 100% korrekt. Der er nemlig introduceret 2 nye typer i .NET 4.0. De ligger begge i System.Numerics namespacet og hedder BigInteger og Complex.

BigInteger har faktisk været en del af frameworket før, men blev pillet ud i 3.5. Nu er typen altså tilbage igen.

Lågens vinder med dette svar er Mads Mau Pedersen.

public static class NumericsExtensions
{
//Brug af Newton-Raphson metoden til at finde heltals kvadratroden.
//Her brugt på BigInteger
public static BigInteger IntegerSqrt(this BigInteger n)
{
if (n < 0)
{
throw new ArgumentOutOfRangeException("n", "value must be 0 or greater.");
}

if (n.IsZero)
{
return BigInteger.Zero;
}

BigInteger guess = n + 1;
BigInteger nextGuess = (n / 2) + 1;

while (nextGuess < guess)
{
guess = nextGuess;
nextGuess = (guess + (n / guess)) / 2;
}
return guess;
}
}

Tillykke, der er en stor dåse bolcher på vej til dig.

I kan downloade deltagernes svar her.

Tags:

Comments

2/14/2010 1:41:32 PM #

اخبار

Thank you very much for the possibility to have a look into the office. Nice boy, he has got the talent to explain.

اخبار Egypt

3/4/2010 8:13:27 AM #

watch movies online

I love watching movies online, it is way cheaper than going to the theaters.

watch movies online United States

3/10/2010 12:01:25 AM #

WoW Mobile

Do you know which cell phone companies allow tethering?

WoW Mobile United States

3/17/2010 2:04:37 AM #

ssk sorgulama

This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.

ssk sorgulama United States

3/17/2010 11:46:15 AM #

arac sorgulama

I admire the valuable information you offer in your articles. I will bookmark your blog and have my children check up here often. I am quite sure they will learn lots of new stuff here than anybody else!

arac sorgulama United States

3/20/2010 3:25:44 PM #

ehliyet

Excellent post.I want to thank you for this informative read, I really appreciate sharing this great post. Keep up your work.

ehliyet Denmark

Add comment


(Will show your Gravatar icon)

(De 3 specielle karaktere i det danske alfabet?)
  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen