INCLUDE Irvine32.inc
.data
num DWORD ?
fact DWORD 1
str1 DB "Enter a number to Calculate Factorial: ",0
str2 DB "The Factorial is: ",0
.code
main PROC
call clrscr
mov edx,OFFSET str1
call WriteString
call ReadDec
mov num,eax
mov ecx,num
L1 :
mov eax,ecx
mov ebx,fact
mul ebx
mov fact,ebx
LOOP L1
mov edx,OFFSET str2
call WriteString
mov eax,fact
call WriteDec
exit
main ENDP
END main
program that take three decimal number as input and find the largest among them in assembly language
8086 assembly language program to check wether given number is perfect or not
A program which is used to count the number of numbers in an array using a 8085 microprocessor is known as a assembly language program.
kjhk
//program to find the factorial value f any number using while loop #include<stdio.h> void main() { int i,n,fact=1; printf("Enter the number\n"); scanf("%d",&n); i=n; while (i>=1) { fact=fact*i; i--; } printf("The factorial value=%d",fact); } the above is a program for calculating tha factorial value of any number which is entered by the user
First of all we will define what factorial is and how to it is calculated.Factional is non negative integer. Notation would be n! It is calculated by multiplying all integers from 1 to n;For example:5! = 1 x 2 x 3 x 4 x 5 = 120.Note: 0! = 1Small C program that illustrates how factorial might be counted:#include int factorial(int num);int main() {int num;printf("Enter number: ");scanf("%d", &num);printf("Factorial: %d\n", factorial(num));return 0;}int factorial(int num) {if (num == 0) {return 1;}return num * factorial(num - 1);}Testing:Enter number: 5Factorial: 120Enter number: 0Factorial: 1
There isn't a reason to write a complete program to do this; in any assembly language just shift the value 1 bit to the left to double it.
int factorial(int n) { int i; int f=1; for(i=2;i<=n;++i) f*=i; return f; }
/*program to find the factorial of a given number*/ #include<stdio.h> #include<conio.h> int fact(int); void main() { int n,c; printf("\n enter the number for which you want to find the factorial"); scanf("%d",&n); c=fact(n); printf("\n the factorial of the number %d is %d",n,fact); getch(); } int fact(int n) { int k; if(n==0) return(1); else k=n*fact(n-1); return(k); }
#include#includeint a,f,n,sum=0; printf("Enter any number"); scanf("%d",&n); f=1; for(a=1;a<=n;a ); { f=f*a; } for(f=1;f<=n;f ); { sum=sum f; } printf("sumation of factorial numbers :",sum); getch(); }
MVI A, 30h MVI B 20h MUL A,B OUT port1 HLT
#include <iostream> using namespace std; int main() { int i, number=0, factorial=1; // User input must be an integer number between 1 and 10 while(number<1 number>10) { cout << "Enter integer number (1-10) = "; cin >> number; } // Calculate the factorial with a FOR loop for(i=1; i<=number; i++) { factorial = factorial*i; } // Output result cout << "Factorial = " << factorial << endl;