Skip to content

3_odd_even_numbers.py code is not optimised  #75

@Aribaskar-jb

Description

@Aribaskar-jb

max = int(input("Enter max number: "))

odd_numbers = []

for i in range(1, max):
if i % 2 == 1:
odd_numbers.append(i)

print("Odd numbers: ", odd_numbers)

The loop is Executed 0(n) times we can reduce as 0(n/2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions