Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

SCSE lO

a013IcsEO6SO SfabaZ

SET- 10

t#Tnclude < stdto.6>


nclude <tîme.h>
tnt fact (tt n)

1f(n== ll ne zo)

ietusrn T

else

etuan fact Cn-0:

int gcdC1nt a, t t b)

(a-o)

1etuxn bS

re tunn gcdCba, a);

votd matn ()

clock-t stast, last, tofal:


a0 l8icSEO6SO S baz
SCSElO
paint f (" ¬nte the m
value\n"):
Scanf (" 7» d", &m)
Parftt ("Cite the nvalue\n" );
Sconf (" 7rdt ", Ln)
Stat= clock C
int mth =
fact (m)
int th =fact CD
Pnttf C"|o");
PortntfC"The mth and nth values ase %d, d\n,
mth, nth);
Pint fC And the GCD of these mth=od Dd
values tS od\n, mth, nth, qcd(mth, oth))
Cast clock C)i
total (last- stat) clock- PE R- SEe ;
Prttf ( Time taken %ld. totac),
Run Debug StopG Share HSave 0)Beu Language C
main.c

9
1e #include<stdio.h>
11#include<time.h>
12 int fact(int n){
13 if(n -= 1 || n == e){
14 return 1
15
16 elset
17 return n*fact(n-1)
18
19
20
21
int gcd(int
if(a =-e
a, int b)
22 return b
23
24
25
return
gcd (b%a, a);
26 void main(){
I
27 int , n
28 clock_t start, last, total;
29 printf("Enter them valuel\n");
30 scanf("%d", &m);
31 printf("Enter the n value\n");
32 scanf("%d", &n);
33 start=clock();
34 int h-£netln
18
19
20 int gcd(int a, int b)
21 if(a -
22 return b
23
24 return scd(ba, )
25
26 void main(){
27 int m, n
28 clock tstart, lest, totalg
29 printf("Enter them value\n")
30 scanf("%d" 8)
31 printf("Enter the n valueln)3
32 scanf("%d". &n)
33 start=clock()
34 int mth fact (m)
35 int nth-fect (n)
36 printf("\n")3
37 printf( The mth and nth values are d, Xd\n,h th);
38 printfAnd the GCD of these mth %d and nth d values is ain", th, nth, gd(t
39 last clock()
40 total (last-start)I CLOCKS PER SEC;
41 printf(Time taken %ld". total);
42
43
input
Enter the m value

Enter the n value


B I

B The mth and nth values are 24, 40320


And the GCD of these mth = 24 and nth =
40320 values is 24
Time taken 0

You might also like