PHY 532 Computational Physics Assignment
PHY 532 Computational Physics Assignment
i=1
s=0
dec=input("Enter decimal to be converted: ")
while dec>0:
rem=dec%2
s=s+(i*rem)
dec=dec/2
i=i*10
print "The binary of the given number is ",s,'.'
raw_input()
Output:
Output
3. Write a python program to find the Greatest common divisor(GCD) of two numbers.
4. Write a python programme to verify a given number is prime or not
Output :
2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 ,
71 , 73 , 79 , 83 , 89 , 97
6. Write a python program to organize a given set of numbers in ascending order using
a. Insertion sort
b. Bubble sort
c. Selection sort
7. Write a python program to find out the Prime number from a sequence of Fibonacci
series.
Program:
def fib(n):
cur = 1
old = 1
i=1
while (i < n):
cur, old, i = cur+old, cur, i+1
return cur
for i in range(10):
print(fib(i))
Output :