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
andriy [413]
4 years ago
11

Write a MATLAB code which asks a user for an integer number and computes the factorial of that number. Use while loop to create

the code.
Computers and Technology
1 answer:
ivann1987 [24]4 years ago
7 0

Answer:

my_int=input('Enter an integer to calculate its factorial: ');

i=1;%Counter to the while loop

r=1;%To keep the result

while i<=my_int

   r=r*i;

   i=i+1;

end

display('The result is:')

r

Explanation:

The factorial is the multiplication of all positive integers from 1 to n , my_int is the value of n in the program, in a while loop you need a condition that is met until all the positive integers have been multiplied, i is the counter that allows this (starts has one and is increasing by one till it gets the value of n)  and also is useful to make the multiplication and r keeps the result of each step until the condition stop being met and then the program the program leaves the loop and displays the solution.

You might be interested in
Which of the following is the best way to add a lengthy explanation to Excel data without being limited to cell sizes and restri
trapecia [35]

Answer:

B

Explanation:

Which of the following is the best way to add a lengthy explanation to Excel data without being limited to cell sizes and restrictions? A. Adding a chart object B. Adding an Access object C. Adding a Word object D. Adding an Excel object microsoft word

Answer: B

6 0
3 years ago
Here is over 40pts as Promised? :)<br> Who invented the Lamborghini?
nordsb [41]

Ferruccio Lamborghini

He is the creator/inventor of the Lamborghini.

3 0
4 years ago
Read 2 more answers
In what type of attack does the attacker send unauthorized commands directly to a database?
Delvig [45]
SQL injection. This is usually cause by the programmer not making the program parse incoming text, therefore allowing an attacker to input database commands.
4 0
4 years ago
Write an HLA Assembly language program that prompts for a specific int8 value named n and then displays a repeated digit pattern
yan [13]

Answer:

Output:

123456

123456

123456

123456

123456

123456

Explanation:

C Code:

#include <stdio.h>

int main() {

int n,i,j;

printf("Gimme a decimal value to use as n:");

scanf("%d",&n);

for(i=0;i<n;i++){

for(j=1;j<=n;j++){

printf("%d",j);

}

printf("\n");

}

return 0;

}

Equivalent assembly program:

.LC0:

.string "Gimme a decimal value to use as n:"

.LC1:

.string "%d"

main:

push rbp

mov rbp, rsp

sub rsp, 16

mov edi, OFFSET FLAT:.LC0

mov eax, 0

call printf

lea rax, [rbp-12]

mov rsi, rax

mov edi, OFFSET FLAT:.LC1

mov eax, 0

call scanf

mov DWORD PTR [rbp-4], 0

.L5:

mov eax, DWORD PTR [rbp-12]

cmp DWORD PTR [rbp-4], eax

jge .L2

mov DWORD PTR [rbp-8], 1

.L4:

mov eax, DWORD PTR [rbp-12]

cmp DWORD PTR [rbp-8], eax

jg .L3

mov eax, DWORD PTR [rbp-8]

mov esi, eax

mov edi, OFFSET FLAT:.LC1

mov eax, 0

call printf

add DWORD PTR [rbp-8], 1

jmp .L4

.L3:

mov edi, 10

call putchar

add DWORD PTR [rbp-4], 1

jmp .L5

.L2:

mov eax, 0

leave

ret

Input:

6

The program was first written with a c code, anf and subsequently translated to an assembly language.

3 0
3 years ago
What is the processing speed for the second generation of computers​
natima [27]

Answer:

10mbps

Explanation:

that's what the internet says

5 0
3 years ago
Other questions:
  • Amy has decided to use a dark background and light colored text for her prensentation. Which toolbar option will let her change
    5·1 answer
  • Computer communications describes a process in which two or more computers or devices transfer ____.
    10·1 answer
  • By default, windows does not display ____________________ in windows explorer.
    8·1 answer
  • 1. If you are 15% years old, you are old enough to obtain
    10·2 answers
  • You have a workstation running windows vista business that you would like to upgrade to windows 7 ultimate. you want to perform
    11·1 answer
  • ???????????????????????​
    10·1 answer
  • #Write a function called hide_and_seek. The function should #have no parameters and return no value; instead, when #called, it s
    7·1 answer
  • Which of the following statements is true?A)Implicit data type conversion is performed when you mix values of different data typ
    5·1 answer
  • Treating others with respect, even when they're impolite, is considered
    13·1 answer
  • Write, compile, and test the MovieQuoteInfo class so that it displays your favorite movie quote, the movie it comes from, the ch
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!