menu
QAmmunity.org
Login
Register
My account
Edit my Profile
Private messages
My favorites
Ask a Question
Questions
Unanswered
Tags
Categories
Ask a Question
Write a program that lets a user enter n and that outputs n! (meaning n*(n-1)*(n-2)*...*2*1). hint: initialize a variable totalvalue to n, and use a loop variable i that counts from n-1 down to 1.
asked
Oct 8, 2018
137k
views
1
vote
Write a program that lets a user enter n and that outputs n! (meaning n*(n-1)*(n-2)*...*2*1). hint: initialize a variable totalvalue to n, and use a loop variable i that counts from n-1 down to 1.
Computers and Technology
college
Cooleronie
asked
by
Cooleronie
7.5k
points
answer
comment
share this
share
0 Comments
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
5
votes
// This code snippet calculates n! and stores the answer in the variable p.
// Handle 0! = 1 separately.
if (n==0) {
p = 1;
}
else {
// Initialize p = n
p = n;
// While loop
while (n>1) {
p = p*(n-1);
n = n-1;
}
}
PatrickD
answered
Oct 14, 2018
by
PatrickD
7.7k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
← Prev Question
Next Question →
Related questions
asked
Aug 15, 2018
62.1k
views
Write a program that lets a user enter n and that outputs n! (meaning n*(n-1)*(n-2)*...*2*1). hint: initialize a variable totalvalue to n, and use a loop variable i that counts from n-1 down to 1. c++
Holdenlee
asked
Aug 15, 2018
by
Holdenlee
9.0k
points
Computers and Technology
college
1
answer
2
votes
62.1k
views
asked
Nov 10, 2021
119k
views
Write a program that lets a user enter N and that outputs N! (N factorial, meaning N*(N-1)*(N-2)*...*2*1). Hint: Initialize a variable total to N (where N is input), and use a loop variable i that counts
Aleksandar Totic
asked
Nov 10, 2021
by
Aleksandar Totic
7.2k
points
Computers and Technology
college
2
answers
5
votes
119k
views
asked
May 8, 2023
185k
views
Victoria Lopez works at a department store. She ispaid on commission. She receives 10% of her first$800 in sales and 20% of the balance of her sales.Last week she earned $1,150. What was the totalvalue
Nils Reichardt
asked
May 8, 2023
by
Nils Reichardt
8.1k
points
Mathematics
high-school
1
answer
3
votes
185k
views
Ask a Question
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.
9.5m
questions
12.2m
answers
Other Questions
“What does it mean when we “rework” copyrighted material?”
The book shows how to add and subtract binary and decimal numbers. However, other numbering systems are also very popular when dealing with computers. The octal (base 8) numbering system is one of these.
Seven basic internal components found in a computer tower
Please help me ! All you do is just put it it all in your own words ! Please this is for my reported card!i don't know how to put it in my own words because my English is not that good!
describe an advance in technology that makes life more enjoyable. what discoveries contribute to this technology?
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search QAmmunity.org