Algo Examples 3
Algo Examples 3
Extract the last digit of number using modulo operator (%) and store it
in digit.
Add digit to sum.
Remove the last digit from number by integer division (/) and store the
result back in number.
5. Power Calculation:
Step 1: Take base and exponent as input.
Step 2: Initialize a result variable to 1.
Step 3: Initialize a counter variable to 0.
Step 4: While the counter is less than the exponent:
4.1: Multiply the result by the base.
4.2: Increment the counter by 1.
Step 5: Print the result.
Step 1: Take an input number from the user and assign it to a variable 'limit'.
Step 2: Initialize variables 'a' and 'b' to store the first two numbers of the
Fibonacci series as 0 and 1, respectively.
Step 3: Print the first two numbers of the Fibonacci series, which are 0 and 1.
Step 4: Initialize a loop counter variable 'i' to 2 to keep track of the current
position in the Fibonacci series.
Step 5: While 'i' is less than or equal to 'limit':
5.1: Calculate the next Fibonacci number by adding 'a' and 'b' and assign
it to a new variable 'next_number'.
5.2: Print the value of 'next_number'.
5.3: Update the values of 'a' and 'b' for the next iteration:
- Assign the value of 'b' to 'a'.
- Assign the value of 'next_number' to 'b'.
5.4: Increment the loop counter 'i' by 1.
Step 6: End the loop.
Step 7: Exit.