Home > Java > Java Program to find factorial of a given number without recursion – Q2

## Java Program to find factorial of a given number without recursion – Q2

Q2: Java Program to find factorial of a given number without recursion

The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n.

For example:
5! =     5*4*3*2*1 = 120
6! = 6*5*4*3*2*1 = 720

```class fact{
public static void main(String args[]){
int num;
long fac = 1;
num = Integer.parseInt(args);
for(int i=1; i<=num; i++){
fac *= i;
}
System.out.println("Factorial of " + num + " is: " + fac);
}
}
```

… from College notes (BCA/MCA assignments):
{"ft_lang_label":"__label__en","ft_lang_prob":0.66750306,"math_prob":0.9962969,"size":733,"snap":"2023-14-2023-23","text_gpt3_token_len":212,"char_repetition_ratio":0.12482853,"word_repetition_ratio":0.11382114,"special_character_ratio":0.3233288,"punctuation_ratio":0.1503268,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99665564,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-06-08T19:21:08Z\",\"WARC-Record-ID\":\"<urn:uuid:7bdd9e9a-4f5c-4774-980e-dcb64ff05e09>\",\"Content-Length\":\"149615\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:222e5faa-b0f4-4769-b618-6ecf36b9a5b3>\",\"WARC-Concurrent-To\":\"<urn:uuid:86975cc2-839e-4d1d-b034-fc69101e0493>\",\"WARC-IP-Address\":\"192.0.78.25\",\"WARC-Target-URI\":\"https://sqlwithmanoj.com/2009/01/01/java-program-to-find-factorial-of-a-given-number-without-recursion-q2/\",\"WARC-Payload-Digest\":\"sha1:VWD2YILWEBK55UFVH5UKTMX7I63T5DMS\",\"WARC-Block-Digest\":\"sha1:RRQDXID3LR6TNLFCYKQ452FIFHJ7PDY2\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224655092.36_warc_CC-MAIN-20230608172023-20230608202023-00555.warc.gz\"}"}