Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function seq ( num ) that prints a sequence of numbers based on the following rules starting with num: If the current number

Write a function seq(num) that prints a sequence of numbers based on the following rules starting with num:
If the current number is even, next number = current number //2-1,
If the current number is odd, the next number = current number -1
Print the numbers of the sequence until the sequence reaches to or below 1.)(1. Note that the value of the first number of the sequence is "num" in the function call and then the series progresses.
Test Cases:
seq(100)
100494823221041
seq(67)
6766321514620
seq(10)
1041
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions