Fundamentals
pow => powerOf => x^y
A simple function I use all the time because I cannot be bothered to remember how to use Math.Pow(). Also, who uses double anyway? Pshh, real men use BigInteger.
using System.Numerics;
public class basic
{
public static BigInteger pow(long down, long up)
{
BigInteger power = 1;
for (long i = 0; i < up; i++)
power *= down;
return power;
}
}
namespace Solution
{
using NUnit.Framework;
using System;
using System.Numerics;
[TestFixture]
public class SolutionTest
{
[Test] public void Test01_ZeroZero() {Assert.AreEqual(BigInteger.Parse("1"),basic.pow(0,0));}
[Test] public void Test02_OneZero() {Assert.AreEqual(BigInteger.Parse("1"),basic.pow(1,0));}
[Test] public void Test03_OneOne() {Assert.AreEqual(BigInteger.Parse("1"),basic.pow(1,1));}
[Test] public void Test04_TwoFive() {Assert.AreEqual(BigInteger.Parse("32"),basic.pow(2,5));}
[Test] public void Test05_ThreeSix() {Assert.AreEqual(BigInteger.Parse("729"),basic.pow(3,6));}
[Test] public void Test06_NineNine() {Assert.AreEqual(BigInteger.Parse("387420489"),basic.pow(9,9));}
[Test] public void Test07_FiftyFifty() {Assert.AreEqual(BigInteger.Parse("8881784197001252323389053344726562500000000000000000000000000000000000000000000000000"),basic.pow(50,50));}
[Test] public void Test08_NinetyNinety() {Assert.AreEqual(BigInteger.Parse("76177348045866392339289727720615561750424801402395196724001565744957137343033038019601000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),basic.pow(90,90));}
[Test] public void Test09_NinetyThousand() {Assert.AreEqual(BigInteger.Parse("17478712517226516096599746191646605705290624874351885178118880118106862662272754892914864698646811110756089506961452765887713684358755086475144142020936384818729123800899771793815296284783205235193191426815044240594108902145005006478139358189257019054026054840981379569793685510258252394113186439979165236770447696626286464065403356279753296192642450797504708624624740911054444373553021461514753480907553301532690679330916994798890898246508417955674786063969756645571437376570270804032399777578652968467400937123779157705360942236880491080232441391830279624844110784644395168452279619352212698147534167825764555073160737519853740460645925467960431507378083145016846797580569059487592463686444161518631380852766035958164109451575997420776176189116011851556020807717467859593598794901919333899652712754031279254322479632696759126461031563439543754427926889360470415335375231379413106908339497677642900813339003803104061547231578821124499916738190541104400010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),basic.pow(90,1000));}
[Test] public void Test10_Million1Thousand1() {Assert.AreEqual(BigInteger.Parse("1001001500666708091584834994213335499316592799502565312583810540758323526911111005634603686669483930857286743754321826864232849418408152954545886264688183157446039791353132425915857008553225953691126792159279415997411004085142266875746137278601021131587158113868597203639654409708386518036416338126344879480116985478676639672346205866699985617039342206813696096706810170372026388963501452270054596444893775441711368157252540330225398329021858809616465044877202437696122829981939260381511865042817499364770669626131656390789928416753321582790621270461663145953182133120159508842586845437332517739774364686813382854131224766878007967286105907099220085280974771001248345281733881815087444582493815359248506399809081455262963218787085971796708784417819709078423903187812206023309677068140671250652909082330966044887996637191644643001870302319446016321894880163091343763655640028627348026712035400168552662422697703087025675971958649891619972332396936779544869629925639642373670755026613785383804881927725955840710845268347727528204377517014451090398856164901406054457183440628124007521515977494906608533538720351729593325872484325368051858401047918905114231318807933763956168773876403630024179473024388226471743723242357056484831047288317527004682585284367156736997972373463352304570926594507764738886718885326634736917706033244678868941980403969141344332066224975739325910854819361961089332061508824940699925326248384186206668892457420714484048177404667198566346782352881670693363356026137100036086857141727005697917953869874510968868018248484064394619071158784988536685221274504268809514743110609402092691517062211247889071133236127462240006097676657804221497058466242982856433715137618975181171442055892128025984140957529945934947580429367312164463215067684695403656822567185772626021450217713080807091703806599434756198984073593789235750865250076955922907862149091151582477906606822061365808922685007970125026827181861447973883348081660930421996213112673271225609243103633310938058449682798195874948680996325465822637699703401778295647585449510161993711316893284253715410839571448646984603994892766639456740927472227613895849854062286515025190447270594059459534461048176276690661491781546540883134519133026079582791853176972560687419707095890773598047052969230399074811688006849486486033296269514427185928906242462789935768827391657448428036897005001657047045856507923647589800995458560931583149390873863211825046851722424886202035465138084799836109844679611489547814741722522514390227230190324651828594598004213598533984362761302413287642776029054834928861570146925209813386829813432836494084882274545988479012735939428163737844542565419279296476195556264651652218020995996003421928128958741067325661359124443276797727774152700246674799545789954731317039218565356236307758432749093754024228019549667790796622235945328608940970142858262177939426123016714310959922364772551492172161899369409188169046873995093320154742139253735820107313761476979274835663610003400393910964736902069862589090207895935256347134118293222818147392020957311239990457555709421060799403429886606172974212004975168681185320799027473448610272316951970666805401235379085666801651919020183004208337548656020151081217467639293789034418776108098220205693082390253105964376566416872433878437921064957486310206717418847701947881161707979395440406394984531218315784213741660332357989635433072469054645314118627108438799299246465189552695071262472675474795958382795444287765929081061044283303836480501817309065136071747767810234950340515765940305017485576522285599871638637272956997453125522645349137778590755296893045837680045826743749161245281838413738604501010326583530787852525869989843978729649205849089461694173231903810650656069896007845191179266759564500656091042888274860228698830512844581442441333669399444971861597929937022501943469451146555380507606110063020637644008716181415089397309743512203166821496059939097526544652755876092104749685012449661783616548342589721117212985155534551037397056891233242319730852629685519619176318313425682437450926437429445422014104886406470837743469298102701651079695342603730690444567039368747829725573255224305666027252854405816616610364867590402328447517993955513395462796498693632162318745129150232692955396565979337001035797332778935795998854716972313617791327730551220342674881439660111907009591856110628857078036746434114739600513920538997113352801438135357663390323476113831697491426043523645996666063187674917654896196583749849408957972958404103163290152954097054604739867014163820206232736380006687978618250323999705212652085787644292654845445474344705588587690103824201195146653435173120067116289222406325664052986272163689804372677998363215942960888420938085738469709186515919182253608885040402809608977237094680900522478635861071348403538358828058609431845880142594087429591459531740117997769012985910607434346155540638303006507453586061022551322253205099968073603257073944008154634006768895142499636451786775112253058327726882296146611809327954024216147969970581215281296011572202359006983414114745750196263631961985615358986417774764132335952866351007929400836937286241074911192762907251057982113973205366794161730098710943049724792420066346944088731249435622488610205448742697765634324416659987330308388601193609655775103865763521733024729866289922869617374564960665738842830884067777819704839721288661110053161340541013277427894784652498016718643541743487249795738580853402703985231307609588063557383670044060471958178085259108652873080390569598586169666021022135984339403534226866143732693865943065734402559787515237069442472866924477711793137412608749874148870441570385555423489812411628903675847379344932656775579369911700489900356106346388586949853593313068998608385351447746911252777240923214493147538094122000280293686974104028381451280774289237646806136759745839759400283494154561874749974061949289938696757191494143697708043545766369956735639882535219357733186610276631445175225464190204819946113276351686130664723930007257208098533408416533291916666500500500001001000001"),basic.pow(1000001,1001));}
}
}