1 Mayıs 2010 Cumartesi

Fibonacci Sayılarını Bulan Python Kodu

fibonacci.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#www.ethemsulan.com
a=0
b=1
while b<100:
  print b
  b,a=a+b,b


pythonda a,b=a ya atanacak deger, b ye atanacak deger gibi bir kullanım var.

Kodu çalıştırısak,


Ethem@Ethem ~ $ chmod 777 fibonacci.py


Ethem@Ethem ~ $ ./fibonacci.py


1


1


2


3


5


8


13


21


34


55


89


Ethem@Ethem ~ $


+x yerine 777 değerini de verebiliriz.

Hiç yorum yok:

Yorum Gönder