Write a Program in python to find the multiple of a number ( the divisor) out of given five numbers

Here’s a Python program to find the multiples of a given divisor out of five numbers provided by the user:


def find_multiples(divisor, numbers):
# Initialize a list to store the multiples of the divisor
multiples = []

# Iterate over each number in the given list of numbers
for num in numbers:
# Check if the number is divisible by the divisor without remainder
if num % divisor == 0:
# If divisible, append the number to the multiples list
multiples.append(num)

# Return the list of multiples of the divisor
return multiples

# Example usage:
def main():
# Ask the user to input the divisor
divisor = int(input(“Enter the divisor: “))

# Ask the user to input five numbers
numbers = []
for i in range(5):
num = int(input(“Enter number {}: “.format(i + 1)))
numbers.append(num)

# Find the multiples of the divisor from the given numbers
result = find_multiples(divisor, numbers)

# Print the multiples found
print(“Multiples of {}: {}”.format(divisor, result))

if __name__ == “__main__”:
main()
“`

This program first asks the user to input the divisor and five numbers. Then, it calls the `find_multiples` function to find the multiples of the divisor among the provided numbers and prints the result.

 

Take a time to connect our other digital creations such as Instagram , Facebook and Youtube.

 

πŸ§‘β€πŸ’»πŸ§‘β€πŸ’» Social Media Links of Tech DCode :

πŸ‘‰πŸ» YouTube : https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
πŸ‘‰πŸ» Instagram : https://www.instagram.com/thetechdcode/
πŸ‘‰πŸ» Facebook Page : https://www.facebook.com/thetechdcode
πŸ‘‰πŸ» Twitter : https://twitter.com/thetechdcode
πŸ‘‰πŸ» Telegram Channel : https://t.me/thetechdcode
πŸ‘‰πŸ» Tech DCode Linktree : https://linktr.ee/thetechdcode
πŸ‘‰πŸ» My Personal Handles : https://linktr.ee/virtualshivamin

πŸ§‘β€πŸ’»πŸ§‘β€πŸ’» Social Media Links of SHIVAM SINGH (OWNER) :

πŸ‘‰πŸ» Instagram : https://www.instagram.com/virtualshivamin/
πŸ‘‰πŸ» Facebook Page : https://www.facebook.com/virtualshivamin/
πŸ‘‰πŸ» Twitter : https://twitter.com/virtualshivamin/
πŸ‘‰πŸ» Personal Linktree : https://linktr.ee/virtualshivamin

Tagged with algorithm, binary search, c++, performance, programming, running time, time complexity

Leave a Reply

Your email address will not be published. Required fields are marked *