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
When you gather primary or secondary data, what part of the market information management process are you participating in?
Umnica [9.8K]

Answer:

Heyyyooo!

The answer is market research.

Hope this helps!

Explanation:

Market research is the way toward gathering, analyzing and interpreting data about a market, about an item or administration to be offered available to be purchased in that advertise, and about the past, present and potential clients for the item or administration; examination into the attributes, ways of managing money, area and necessities of your business' objective market, the industry all in all, and the specific contenders you confront.  

3 0
3 years ago
How many answers do you need to be able to write messages on here??
Kipish [7]

1,000

Hope this helps!



~Courtney

3 0
3 years ago
Microsoft Word cannot be used to create personalized web<br> pages.<br> OTrue<br> False
Georgia [21]

Answer:

False

Explanation:

Because Microsoft can be used to create personalized web

5 0
2 years ago
Write a program in C which will open a text file named Story.txt. You can create the file using any text editor like notepad etc
ddd [48]

Answer:

See explaination

Explanation:

#include <stdio.h>

#include <stdlib.h>

int main()

{

FILE * file_object;

char file_name[100];

char ch;

int characters=0, words=0;

printf("Enter source file name: ");

scanf("%s", file_name); //asking user to enter the file name

file_object = fopen(file_name, "r"); //open file in read mode

if (file_object == NULL)

{

printf("\nUnable to open file.file not exist\n"); //check if the file is present or not

}

while ((ch = fgetc(file_object)) != EOF) //read each character till the end of the file

{

if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\0') //if character is space or tab or new line or null character increment word count

words++;

else

characters++; //else increment character count this assures that there is no spaces count

}

printf("The file story.txt has the following Statistics:\n"); //finally print the final statistics

if (characters > 0)

{

printf("Words: %d\n", words+1); //for last word purpose just increment the count of words

printf("Characters (no spaces): %d\n", characters);

}

fclose(file_object); //close the file object

return 0;

}

6 0
3 years ago
Explain the term computer output​
fomenos

Answer:

Computer output simply put is any data generated by the computer or feedback gotten from the computer. Output can take many forms, but there are 2 major categories:

- Soft copy output e.g text viewed on a computer screen

- Hard copy output e.g printouts

Explanation:

6 0
3 years ago
Other questions:
  • When would a one way flag variable be used
    10·1 answer
  • During the forensic phase of a security investigation, it was discovered that an attacker was able to find private keys on a poo
    9·1 answer
  • 3. The term integration refers to the ability to
    6·1 answer
  • A project manager type a document and print it he is using
    14·1 answer
  • You want to establish the validity of a test designed for computer technicians using a predictive criterion-related validation s
    9·1 answer
  • Define a new class Fighter that inherits from Spaceship. Add a variable property weapon that defaults to an empty string and a v
    14·1 answer
  • If a student passes off an author’s work as his or her own, the student has
    6·1 answer
  • You Could Never Size Me UP! Been Doing This Sh*t A Long ⏱time
    15·1 answer
  • How to block admin on school chromebook managed by admin
    9·2 answers
  • True or false: Concurrent validation is more time consuming to measure than predictive validation because it involves a wait per
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!