Kirit,

Forgive me for using Ruby--the scoping won't even be "Haskell correct"
until version 1.9, but I think it will do for this problem. I believe
the answer should be

def peasant(n, power)
case power.divmod(2).collect{|i|i.zero?}
    when [true,true] : 1
    when [false,true] : peasant(n * n, power/2)
    else n *  peasant(n * n, power/2)
    end
  end

  puts peasant(3 ,1000).to_s

 =>

132207081948080663689045525975214436596542203275214816766492036822682859734
670489954077831385060806196390977769687258235595095458210061891186534272525
795367402762022519832080387801477422896484127439040011758861804112894781562
309443806156617305408667449050617812548034440554705439703889581746536825491
613622083026856377858229022841639830788789691855640408489893760937324217184
635993869551676501894058810906042608967143886410281435038564874716583201061
4366132173102768902855220001


On Oct 7, 11:32 am, "Kirit Sælensminde" <[EMAIL PROTECTED]>
wrote:
> I don't know where we should meet on Thursday, but I'm pleased to say that
> at least the BeerCamp puzzles are back again:
>    http://www.kirit.com/Blog:/2008-10-07/Powers
>
> Kirit
>
> 2008/10/6 Dvlong <[EMAIL PROTECTED]>
>
>
>
> > Krua Nai Baan on Langsuan has reasonable food and prices, and a
> > private room or two that would be large enough.  It's near Sarasin on
> > the West side of the Road.
>
> > On Oct 5, 3:52 pm, "proteus guy" <[EMAIL PROTECTED]> wrote:
> > > Any suggestions/ideas for a location for the upcoming BeerCamp this week?
>
> > >   -- Ben
>
> --http://www.kirit.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Barcamp Thailand" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/barcamp-thailand?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to