Re: [algogeeks] Re: number calculation

2010-05-19 Thread Mario Ynocente Castro
http://code.google.com/codejam/contest/dashboard?c=32016#s=aa=2

2010/5/19 Adrian kri...@gmail.com


 The only solution I can think of is to use the binomial theorem
 (http://en.wikipedia.org/wiki/Binomial_theorem) to expand
 (3+sqrt(5))^n . Then you only need to take into the account the terms
 where y (sqrt(5)) has an odd power because all others are integers and
 won't affect the decimals. Then after adding them up you'll end up
 with something like n * sqrt(5) where n is the total of the
 coeficients of sqrt(5) and then just do the math and find out the 3
 decimals.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Mario Ynocente Castro
Undergraduate Student of System Engineering
National University of Engineering, Peru

http://sites.google.com/site/ycmario

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: number calculation

2010-05-19 Thread Piyush Verma
let @=3+sqrt(5)
so @^n = (3+sqrt(5))^n =(an+bn*sqrt(5))

@^(n-1)=(3+sqrt(5))*(an+bn*sqrt(5))

so an+1=3an+5bn
 bn+1=an+3bn
so [an bn]= A [an-1 bn -1]
   = A^n [a0 b0]   where a0=1 and b0=0
where a= [ 3   5,1   3]

calculate an and bn in each step and devide it by 1000 for next an and bn

at end step ans=(an + bn*sqrt(5)) mod 1000

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.