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
Vlad [161]
4 years ago
8

Write a recursive function that returns the product of the digits of its integer input parameter, n. You omay assume that n is n

on-negative. For example, productDigits(243) should return 24, since 2 x 4 x 3
Computers and Technology
1 answer:
IceJOKER [234]4 years ago
7 0

Answer:

The solution code is written in Python:

  1. def productDigits(n):
  2.    if(n // 10 == 0  ):
  3.        return n
  4.    else:
  5.        return (n%10) * productDigits(n//10)

Explanation:

Firstly we define a function named it as productDigits which takes one input parameter, n. (Line 1)

Next, we create if-else statements by setting the condition if the input n divided by 10 is equal to 0 (this means the n is only 1 digit), the program shall return the n (Line 3-4).

Otherwise, the program will return the remainder of the n divided by 10 multiplied with the output of the recursive function calling with input n//10 (Line 5-6).

Please note the usage of // is to discard the decimal point of the division result.

You might be interested in
Variables defined inside a member function of a class have: Block scope. Class or block scope, depending on whether the binary s
Snowcat [4.5K]

Answer:

The answer is "Block scope".

Explanation:

In the programming, the scope is a code, in which it provides the variable ability to exist and not be retrieved beyond variable. In this, the variables could be defined in 3 locations, that can be described as follows:

  • Inside a method or the block, which is also known as a local variable.
  • Outside of the method scope, which is also known as a global variable.
  • Defining parameters for functions known as formal parameters.
8 0
4 years ago
You have one IP address provided from your ISP with a /30 mask. However, you have 300 users that need to access the Internet. Wh
DedPeter [7]

Answer:

A. PAT.

Explanation:

Based on the detail given the technology I will

basically use to help implement the solution will be PAT which full meaning is PORT ADDRESS TRANSLATION reason been that PAT is a technology that enables multiple users to have access to the internet and secondly PORT ADDRESS TRANSLATION (PAT) can often share one IP public address to multiple or different internet users at a time.

8 0
3 years ago
Although saying "Cylinder IS A Circle" doesn't make sense, it can be implemented in Java using inheritance in a legitimate way.
allochka39001 [22]

Answer:

I've included in the codes the area to circle and volume to cylinder. The Volume method that was used, area() to compute, the volume of cylinder which shows that cylinder is an expansion of circle with an extra dimension (height)

Explanation:

Temp is tester class

public class Temp {

   public static void main(String[] args) {

       Circle c = new Circle(7);

       System.out.println("Area of circle with radius 7 is "+c.area());

       Cylinder c1 = new Cylinder(7,10);

       System.out.println("Cylinder volume with radius 7 and height 10: "+c1.volume());

   }

}

----------------------------------------------------------------------------------------------------

class Circle{

   int radius;

   Circle(int r){

       radius=r;

   }

   double area(){  //area of circle

       return 3.14*radius*radius;

   }

   public int getRadius() {

       return radius;

   }

   public void setRadius(int radius) {

       this.radius = radius;

   }

}

class Cylinder extends Circle{

   int height;

   Cylinder(int r, int h){

       super(r);

       height=h;

   }

   double volume(){  //volume of cylinder

       return area()*height;

   }

   public int getHeight() {  //accessor

       return height;

   }

   public void setHeight(int height) {  //mutator

       this.height = height;

   }

}

8 0
4 years ago
What is the name of the organization responsible for assigning public ip​ addresses?
Veseljchak [2.6K]
Comcast,at&t,and Verizon
8 0
3 years ago
Damian has uploaded an animation he created using Director to his website. However, his friend Teri cannot view the video. What
IrinaK [193]
His software might be outdated or he might have the wrong software.
3 0
3 years ago
Other questions:
  • Which relationship is possible when two tables share the same primary key?
    9·2 answers
  • Are video games considered information technology
    9·2 answers
  • Why do most programmers indent the conditionally executed statements in a decision structure?
    7·1 answer
  • 8.8 Lab: Swapping variables Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the
    15·1 answer
  • Which of the following is similar to defense in depth and supports multiple layers of security?a. Defense in depthb. Diversity o
    7·1 answer
  • In the circuit shown in the figure above, what will happen when switches S1 and S3 are both closed? 
    8·1 answer
  • Is this right? I’m not sure
    15·1 answer
  • Which statement about routers is !!!FALSE!!!
    10·1 answer
  • When you get a new sim card do it come with a new number or do you have a activate the phone and get a new number in store ?
    9·1 answer
  • What is the purpose of flight simulator programs, and what are some of the benefits of using them?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!