Consecutive Multiples X22793


Statement
 

pdf   zip   main.py

thehtml

Write a funcion consecutive_multiples that receives a list of strictly positive integers and returns the number of elements that are multiple of the preceding one.

Observation

Submit just the function with no main program. If you have a test main, comment it out, or put it inside a conditional if __name__ == "__main__"

Sample session
>>> consecutive_multiples([1, 4, 5, 2, 8, 5, 10, 9, 23, 6, 18, 7])
4
>>> consecutive_multiples([4, 6, 7, 21, 7, 10, 1, 12, 3, 21])
3
>>> consecutive_multiples([5])
0
>>> consecutive_multiples([3, 12])
1
>>> consecutive_multiples([3, 3, 3, 3])
3
Information
Author
Lluís Padró
Language
English
Official solutions
Python
User solutions