Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A (finite) sequence s_0, s_1, ..., s_{n - 1} of integers is called a happy sequence if each two consecutive elements have a common divisor
A (finite) sequence s_0, s_1, ..., s_{n - 1} of integers is called a happy sequence if each two consecutive elements have a common divisor which is greater than 1, i.e. if gcd(s_i, s_{i + 1}) > 1 for all i. In Python, the sequence can be represented by a list [s_0, s_1, ..., s_{n - 1}]. Write a functions is_happy(l) that will get a list l that contains integers. The function should return True if the list contains a happy sequence, and False otherwise.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started