1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Aleks [24]
3 years ago
15

Create a function (prob3_6) that will do the following: Input a positive scalar integer x. If x is odd, multiply it by 3 and add

1. If the given x is even, divide it by 2. Repeat this rule on the new value until you get 1, if ever. Your program will output how many operations it had to perform to get to 1 and the largest number along the way.
Computers and Technology
1 answer:
aniked [119]3 years ago
5 0

Answer:

Following are the program in python language

def prob3_6(k): #function definition

  c = 0 #variable declaration

  while k != 1: #iterating the while loop

      print(k) #print k

      if k % 2 == 0:#check if condition  

          k= k // 2 #divisible by 2

      else: #else condition

          k = k * 3 + 1  

      c = c + 1

  print(k) #print k

  print c #print count

prob3_6(3)#function call

Output:

3

10

5

16

8

4

2

1

7

Explanation:

Following are the description of program

  • Create a function "prob3_6" in this function we passing an integer parameter of type "int" named "k".
  • Inside that function we declared a variable "c" of type "int" that is used for counting purpose .
  • After that we iterated the while for print the value of when it is not equal to 1 .
  • We check if condition when k gives 0 on modulus then k is divisible by 2 otherwise else block will be executed in the else part we multiply by 3 to k and add 1 to the k variable .
  • Finally print "k" and "c"

You might be interested in
3. Megan and her brother Marco have a side business where they shop at flea markets, garage sales, and estate
Neko [114]

Answer:

a

Explanation:

Megan doesn't have a registered business. She can't claim insurance

4 0
3 years ago
A write the result P*=++j where j is 24
MariettaO [177]

Answer:

ang hrap nmn nyan

Explanation:

poede po

7 0
3 years ago
You can apply several different worksheet themes from which tab?
Nookie1986 [14]

page layout...... im not sure

6 0
3 years ago
Read 2 more answers
Yan wants to attract customers specifically searching on Google for Time-B-Gone, his company's unique office-support product. Hi
ch4aika [34]

Answer:

The answer is "Option A".

Explanation:

The interactive background advertisements, that use advanced internet navigation technology from Google to dynamically resolve specific information demands based on the quality of a network page are also referred to as interactive search ads. This ads are good for tactics, and certain options were incorrect, that can be defined as follows:

  • In option B, It allows you easily access all other URLs of creative online ads.
  • In option C, It helps regulate operation in a machine.
  • In option D, It grows the internet traffic.
6 0
3 years ago
"The ______ of an operational system that supports an organization includes policies, requirements, and conditional statements t
Serggg [28]

Answer:

decision logic

Explanation:. The decision logic of an operational system that supports an organization includes policies, requirements, and conditional statements that govern how the system works. These systems includes the following :

a) Order processing,

b)Pricing

c) Inventory control, and

d) Customer relationship management. And the traditional means of modifying the decision logic of information systems involves heavy interaction between business users and information technology (IT) analysts.

3 0
4 years ago
Other questions:
  • I’m which scenario would someone most likely be using presentation software ?
    6·2 answers
  • Graphs and charts are two different elements. True or False
    15·1 answer
  • Your organization's network has multiple layers of security devices. When you attempt to connect to a service on the Internet. H
    9·1 answer
  • Develop a C++ program that will determine whether a department store customer has exceeded the credit limit on a charge account.
    13·1 answer
  • ____ is the official web portal for the U.S. government, providing access to all official U.S. government services and informati
    12·1 answer
  • Assume phrase= "Peter Piper picked a peck of pickled peppers", What will be returned if phrase.search(/[aeiou]/) is called?
    9·1 answer
  • How to delete Brainly account ?​
    12·1 answer
  • A digital forensic analyst examines the original digital source (e.g. computer, flash drive, backup tape) suspected of being inv
    5·1 answer
  • What is the difference between MySQL and MariaDB?
    9·1 answer
  • Help help help help help help help help
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!