AJ's Code blog

spoj solutions and other codes in python, C , C++

Sunday, 10 February 2013

Lucas number

def Lucas(n):
    a=[]
    i=0
    while i!=n+1:
        if i==0:
            a.append(2)
        elif i==1:
            a.append(1)
        else:
            a.append(a[i-1]+a[i-2])
        i+=1   
    return a[n]       

print Lucas(input())


Read more about Lucas Number..           
Posted by Coding man at 05:26
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: Python codes

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2014 (3)
    • ►  November (3)
  • ▼  2013 (94)
    • ►  October (4)
    • ▼  February (32)
      • Number to Word
      • Tiling a Grid With Dominoes
      • Househoder Method and Jacobi Rotaion
      • Circular Track
      • Size Contest
      • Tanks
      • H Number
      • Azooz
      • Word To Number
      • Egypt
      • Pizza
      • GCD (very large numbers)
      • Binary GCD
      • GCD2
      • Euler Totient Function
      • Cards
      • Recaman’s Sequence
      • A Game with Numbers
      • Binary Stirling Numbers
      • Armstrong number
      • Ambiguous Permutations
      • Street Parade
      • Sieve of Eratosthenes
      • 28 digits of phi (Golden ratio)
      • 27 digits of e (Euler's number)
      • Lucas number
      • 1 Lac Digits of Pi
      • Cube Root Truncation
      • Heptadecimal Numbers
      • Last Non-Zero Digit of Factorials
      • Tridiagonalization using Given's Method
      • 8057. Square Free Factorization Problem code: AMR10C
    • ►  January (58)

About Me

Coding man
View my complete profile
Simple theme. Powered by Blogger.