DeveloperBreeze

Generate Fibonacci Sequence

def fibonacci(n):
    if n <= 1:
        return n
    else:
        return fibonacci(n-1) + fibonacci(n-2)

result = [fibonacci(i) for i in range(10)]
print('Fibonacci Sequence:', result)

Continue Reading

Discover more amazing content handpicked just for you

Code
javascript

Prime Number Check and Prime Number Generation in JavaScript

No preview available for this content.

Jan 26, 2024
Read More
Code
php

Recursive Factorial Calculation in PHP

// Function to calculate factorial using recursion
function factorial($n) {
    if ($n === 0) {
        return 1;
    }
    return $n * factorial($n - 1);
}

// Usage: Calculate factorial of 5
$result = factorial(5);

Jan 26, 2024
Read More
Code
python

Binary Search in Python

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Fibonacci Sequence in JavaScript

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Sort a List

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Calculate Sum of Numbers in a List Using sum() Function

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Generate List of Even Numbers Using List Comprehension

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Find Maximum Number in List Using max() Function

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Find Maximum Number in Array Using Math.max

No preview available for this content.

Jan 26, 2024
Read More
Code
java

Swap Two Numbers Without Using a Temporary Variable

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Remove Duplicates from Array Using Set

No preview available for this content.

Jan 26, 2024
Read More
Code
java

Calculate Factorial

No preview available for this content.

Jan 26, 2024
Read More
Code
csharp

Calculate Sum of Numbers in Array

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Create a NumPy 1D Array

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Reshape NumPy Array

The following Python code demonstrates how to reshape a one-dimensional array into a two-dimensional array using NumPy:

import numpy as np

# Define a one-dimensional array
arr = np.array([1, 2, 3, 4, 5, 6])

# Reshape the array into a 2x3 matrix
reshaped_arr = arr.reshape(2, 3)
print(reshaped_arr)

Jan 26, 2024
Read More
Code
python

Performing Addition and Multiplication on NumPy Arrays

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Filtering and Selecting Elements in NumPy Array

No preview available for this content.

Jan 26, 2024
Read More
Code
json python

Append Data to JSON File

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!