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
Allushta [10]
3 years ago
13

Write a program that asks the user to input a positive integer and then calculates and displays the factorial of the number. The

program should call a function named getN
Computers and Technology
1 answer:
mestny [16]3 years ago
6 0

Answer:

<em>The program is written in python and it doesn't make use of any comment; </em>

<em>(See explanation section for line by line explanation)</em>

def getN(num):

     fact = 1

     for i in range(1, 1 + num):

           fact = fact * i

     print("Factorial: ",fact)

num = int(input("Number: "))

if num < 0:

     print("Invalid")

else:

     getN(num)

Explanation:

The function getNum is defined here

def getN(num):

Initialize the result of the factorial to 1

     fact = 1

Get an iteration from 1 to the user input number

     for i in range(1, 1 + num):

Multiply each number that makes the iteration

           fact = fact * i

Print result

     print("Factorial: ",fact)

Ths line prompts user to input number

num = int(input("Number: "))

This line checks if user input is less than 0; If yes, the program prints "Invalid"

if num < 0:

     print("Invalid")

If otherwise, the program calls the getN function

else:

     getN(num)

You might be interested in
Which of the Arts, A/V Technology, and Communication career cluster pathways are involved with producing a product for an audien
PIT_PIT [208]

I believe the pathways are Audio/Visual Technology and Film, Journalism and Broadcasting and Printing Technology .


5 0
3 years ago
Read 2 more answers
Can anyone can tell me and explain me the answer of it please .<br>thanks
lawyer [7]
Line 2 i looked it up on my phone
7 0
3 years ago
#A year is considered a leap year if it abides by the #following rules: # # - Every 4th year IS a leap year, EXCEPT... # - Every
lara [203]

Answer:

To check if the year comes under each 100th year, lets check if the remainder when dividing with 100 is 0 or not.

Similarly check for 400th year and multiple 0f 4. The following C program describes the function.

#include<stdio.h>

#include<stdbool.h>

bool is_leap_year(int year);

void main()

{

int y;

bool b;

 

printf("Enter the year in yyyy format: e.g. 1999 \n");

scanf("%d", &y);     // taking the input year in yyyy format.

 

b= is_leap_year(y);  //calling the function and returning the output to b

if(b==true)

{

 printf("Thae given year is a leap year \n");

}

else

{

 printf("The given year is not a leap year \n");

}

}

bool is_leap_year(int year)

{

if(year%100==0)   //every 100th year

{

 if(year%400==0)   //every 400th year

 {

  return true;

 }

 else

 {

  return false;

 }

}

if(year%4==0)  //is a multiple of 4

{

 return true;

}

else

{

 return false;

}

}

Explanation:

Output is given as image

5 0
3 years ago
Is it possible for a PowerPoint user to add notes to slides and see the added comments
Arturiano [62]

Answer:

I am not for sure on this, but yes I think it is possible for the PowerPoint user to add notes to slides and see the added comments. If it isn't possible I know for a fact on Google slides it is possible.

:

hope this helps! :)

7 0
3 years ago
Who developed the idea of a universal network?
polet [3.4K]
Alan Turing fathered the machines we now lovingly call computers, however it was Nicola Tesla that birthed the idea of a world-wide wireless system.
7 0
3 years ago
Other questions:
  • Using the merge method of the Map interface, which statement correctly updates the salesTotalByDept map of type Map to update th
    7·1 answer
  • Which answer best describes an unsubsidized federal loan
    9·1 answer
  • Why might a government entity choose to offer some information and services online as in e-government
    8·2 answers
  • You could be electrocuted if you try to use water to put out a
    14·2 answers
  • Suppose your name was Alan Turing. Write a statement that would print your last name, followed by a comma, followed by a space a
    10·1 answer
  • You are requesting information about wireless connectivity for your workplace computers. Because you expect the information to b
    15·1 answer
  • If E=mc2 then what does F equal?
    10·1 answer
  • Clicking the ____ opens the insert function dialog box.
    13·1 answer
  • In cell B13, create a formula without a function using absolute references that subtracts the values of cells B5 and
    13·1 answer
  • the application you attempted to authenticate to is not authorized to use cas. contact your cas administrator to learn how you m
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!