#include < stdio.h >
int fact(int);
int main()
{
    int no,ans;
    scanf("%d",&no);
    ans=fact(no);
    printf("%d",ans);
    return 0;
}
int fact(int a)
{
    int f;
    if(a==0)
    {
        return 1;
    }
    f=a*fact(a-1);
    {
        return f;
    }
}
ei code er akta jinish bujhlam na..j 'a' jkhn 1 hoy tkhn to f=0 hoar ktha but ans thik asheche kivabe?

asked 11 Feb '17, 06:39

tazzina's gravatar image

tazzina
353

edited 02 Mar '17, 04:26

menon's gravatar image

menon
4.7k334


কারণ আপনি fact ফাংশনের মধ্যে যে if কন্ডিশন দিয়েছেন সেখানে আপনি a == 0 হলে return 1 করতেছেন ।

ধন্যবাদ :)

permanent link

answered 11 Feb '17, 09:00

menon's gravatar image

menon
4.7k334

f=0 hocche...a to tkhn 0 hche na..a hochhe 1..tkhn f=0 hchche..

(11 Feb '17, 15:13) tazzina
fact(0) = 1

fact(1) = 1*fact(1-1) = 1*fact(0) = 1
permanent link

answered 23 Feb '17, 12:06

mahrahat's gravatar image

mahrahat
8727

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×402
×7

question asked: 11 Feb '17, 06:39

question was seen: 730 times

last updated: 02 Mar '17, 04:26