Skip to main content

Posts

Fibonacci series in Python

  Fibonacci series in Python The Fibonacci series is a sequence of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The series is named after the Italian mathematician Leonardo Fibonacci, who introduced it to the Western world in his 1202 book "Liber Abaci." The Fibonacci sequence has many interesting properties and appears in various areas of mathematics and science. It is often used as a simple example to introduce the concept of recursion (where a function calls itself). Here is the first few terms of the Fibonacci series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ... As you can see, each term is the sum of the previous two terms. For example, the third term (1) is the sum of the first two terms (0 and 1), the fourth term (2) is the sum of the second and third terms (1 and 1), and so on. The Fibonacci series has many interesting properties and appears in various areas of mathematics and science. It is often used as a simple examp...
Recent posts

Armstrong number in Python

Armstrong number An Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits. For example, 153 is an Armstrong number because: 1^3 + 5^3 + 3^3 = 153 Other Armstrong numbers include 371, 407, and 1634. To check if a number is an Armstrong number, you can use the following algorithm: Calculate the number of digits in the number. For each digit in the number, raise it to the power of the number of digits and add it to a running total. If the running total is equal to the original number, the number is an Armstrong number. For example, to check if 371 is an Armstrong number: The number of digits in 371 is 3. 3^3 + 7^3 + 1^3 = 27 + 343 + 1 = 371. The running total is equal to the original number, so 371 is an Armstrong number. I hope this helps! Let me know if you have any other questions. Here is some sample Python code that checks if a number is an Armstrong number: Program: def is_armstrong_number(num): # convert the number to a st...