Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gitlab-inlab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
codecatalyst33
gitlab-inlab
Commits
8df2086c
Commit
8df2086c
authored
Aug 10, 2017
by
CHINTHAREDDY SAI CHARITH REDDY
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload new file
parent
36a663ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
lab1/problem2.cpp
lab1/problem2.cpp
+38
-0
No files found.
lab1/problem2.cpp
0 → 100644
View file @
8df2086c
#include<iostream>
#include<ctime>
using
namespace
std
;
long
long
factorial
(
int
n
){
if
(
n
==
0
)
return
1
;
else
return
n
*
factorial
(
n
-
1
);
}
int
main
(){
int
n
;
cin
>>
n
;
long
long
fac
=
1
;
int
start
=
clock
();
for
(
int
i
=
1
;
i
<=
n
;
i
++
){
fac
*=
i
;
}
int
stop
=
clock
();
cout
<<
fac
<<
"
\n
"
;
start
=
clock
();
cout
<<
factorial
(
n
);
stop
=
clock
();
cout
<<
"
\n
"
;
}
/*
time taken by iterative way
n=10 t=0
n=12 t=1
time taken by recursive way
n=10 t=1
n=12 t=1
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment