Posts

Showing posts with the label Factorials

Unlocking Python's Potential: Exploring Fibonacci Series, Factorials, Prime Numbers, and Temperature Conversion

  Here are a few more simple programs that you can try: Fibonacci Series This program generates and prints the Fibonacci series up to a specified number of terms. python Copy code n = int ( input ( "Enter the number of terms: " )) # Initialize the first two terms a, b = 0 , 1 print ( "Fibonacci Series:" ) for _ in range (n): print (a, end= " " ) a, b = b, a + b Factorial Calculation This program calculates the factorial of a given number. python Copy code n = int ( input ( "Enter a number: " )) factorial = 1 for i in range ( 1 , n + 1 ): factorial *= i print ( "The factorial of" , n, "is" , factorial) Prime Number Check This program checks whether a given number is prime or not. python Copy code num = int ( input ( "Enter a number: " )) is_prime = True if num > 1 : for i in range ( 2 , int (num ** 0.5 ) + 1 ): if num % i == 0 : is_prime = False brea...