algorithm
algorithm
BSIT 2-C
- (Take π as 3.14159).
- Otherwise, it is odd.
- If year % 4 == 0:
- Check if year % 100 == 0:
- Set I = 1.
- Increment i by 1.
- For `I = 1` to `n`:
- For `I = 3` to `n`:
- Print `next_term`.
- Decrement `end` by 1.
- For `I = 0` to `n-1`:
- For `j = 0` to `n-i-2`:
Here are the algorithms for **Tasks 21 to 49** divided into sections for readability:
**Step 4:** Call the respective function and display the result.
**Algorithm to find the greatest common divisor (GCD) using the Euclidean method.**
- While `b != 0`:
- Update `b = a % b`.
- Update `a = temp`.
- Update `n = n // 10`.
- If the character is in `{‘a’, ‘e’, ‘I’, ‘o’, ‘u’}` (case insensitive), increment `vowel_count`.
**Step 3:** Open the file in write mode and write the content.
**Step 3:** Loop through the words and find the longest.
Here are the algorithms for **Tasks 36 to 40**, focusing on recursion-based problems:
- Return `n * factorial(n-1)`.
**Step 5:** Call the function `factorial(n)` and display the result.
**Step 5:** Call the function `fibonacci(n)` and display the result.
**Final Step:** End the algorithm.
**Step 5:** Call the function `sum_of_digits(n)` and display the result.
**Step 5:** Call the function `gcd(a, b)` and display the result.
**Step 5:** Call the function `power(base, exp)` and display the result.
**Step 3:** Extract digits and calculate the sum of their cubes:
- Check if `num` is prime (use the prime-checking logic from Task 14).
- For `I = 1` to `n`:
- Check if `num` is prime (use the prime-checking logic from Task 14).
- Print `value`.
- Print `j`.