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
dlinn [17]
2 years ago
14

Does anybody know the answer to 5.7.5: Factorial of Code HS? I can’t figure it out

Computers and Technology
2 answers:
shutvik [7]2 years ago
4 0

function myFunction(num){

 n = 0;

 total = 1;

 while (n < num){

   total *= (num - n);

   n+=1;

 }

 return total;

}

alert(myFunction(6));

I'm not too proficient in JavaScript but here's what the function would look like. I hope this helps!

spin [16.1K]2 years ago
3 0

Answer:

the answer is

var N = readInt("Enter a starting value for the factorial: ");

var total = 1;

function start(){

 

for(var i = 0; i < N; i++) {

total = total * (N - i);

}

println(N + "! = " + total);

}

Explanation:

You might be interested in
Someone is retiring next year. What would be an appropriate amount of risk to take their investments?
slamgirl [31]
B...............................
7 0
2 years ago
Read 2 more answers
Write a parent program to fork(2) n processes where n is passed tothe program on the command line, and n can be from 1 to 10. Al
MrRissso [65]

Answer:

Complete code is given below:

Explanation:

#include <stdio.h>

#include <sys/types.h>

#include <unistd.h>

#include <time.h>

#include <sys/wait.h>

int main(int argc , char *argv[]){

pid_t mypid, childpid;

int status;

int i,n;

time_t t;

     

mypid = getpid();

printf("pid is %d.\n", mypid);

childpid = fork();

if ( childpid == -1 ) {

perror("Cannot proceed. fork() error");

return 1;

}

 

 

if (childpid == 0) {

 

 

mypid = getpid();

 

 

childpid = fork();

if ( childpid == -1 ) {

perror("Cannot proceed. fork() error");

return 1;

}

 

if (childpid == 0) {

 

mypid = getpid();

printf("Child pid is %d.\n", getppid());

 

childpid = fork();

 

 

if ( childpid == -1 ) {

perror("Cannot proceed. fork() error");

return 1;

}

random((unsigned) time(&t));

printf(" parent id = %d : Random = %d\n",mypid , (int)(random()% 100 +1));

printf("child id = %d : Random = %d\n",getpid , (int)(random()% 100 +1));

 

if (childpid == 0) {

 

printf("Child 2: I hinerited my parent's PID as %d.\n", mypid);

 

mypid = getpid();

printf("Child 2: getppid() tells my parent is %d. My own pid instead is %d.\n", getppid(), mypid);

 

sleep(30);

return 12;

} else return 15;

} else {

 

while ( waitpid(childpid, &status,0) == 0 ) sleep(1);

 

if ( WIFEXITED(status) ) printf("Child 1 exited with exit status %d.\n", WEXITSTATUS(status));

else printf("Child 1: child has not terminated correctly.\n");

}

} else {

printf(" fork() is ok and child pid is %d\n", childpid);

wait(&status);

 

if ( WIFEXITED(status) ) printf(" child has exited with status %d.\n", WEXITSTATUS(status));

else printf(" child has not terminated normally.\n");

}

 

return 0;

}

Output:

pid is 24503.

Child   pid  is 24565.

parent id = 24566 : Random = 87

child id = 1849900480 : Random = 78

pid is 24503.

Child 1  exited with exit status 15.

pid is 24503.

fork() is ok and child pid is  24565

child has exited with status 0.

6 0
3 years ago
are designed to locate information based on the nature and meaning of Web content, not simple keyword matches Select one: a. Cra
san4es73 [151]

Answer: C. Semantic Search Engines

Explanation:

Semantic search is simply search with meaning. It is designed to locate information based on the nature and meaning of Web content, not simple keyword matches (like in lexical searches)

4 0
3 years ago
What is a variable in programming?
HACTEHA [7]
A symbol or set of characters in a programming statement whose value can be changed
3 0
3 years ago
Explain the basic operations of a computer system​
Leona [35]

Answer:

Basically computer does 5 basic operations that are input, output, process,storing and controlling. Input is basically taking data from the user, processing is transferring that data into useful information, then that information needs to be stored and controlled and finally output is give to user.

5 0
2 years ago
Read 2 more answers
Other questions:
  • You have been contracted by a local school to evaluate their computer labs for security threats. They are most worried about the
    6·1 answer
  • Consider the following class definitions. public class BClass { private int x; public void set(int a) { x = a; } public void pri
    11·1 answer
  • Which of the following is not a general strategy for organizing and analyzing qualitative data?a.Convert the data into one or mo
    6·1 answer
  • C programming question:
    12·1 answer
  • Suppose we provide a new implementation of the transport layer protocol tcp providing the same functionality using different alg
    14·1 answer
  • In which step of web design is storyboarding helpful?
    14·1 answer
  • 2.
    8·1 answer
  • Cine stie repede va rog mult si repede
    9·1 answer
  • Select the correct answer.<br> What do you understand by "exposition"?
    10·2 answers
  • Desktop computers have a(n) ________ unit, located within the system unit, that plugs into a standard wall outlet, converts AC t
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!