Skip to content

Added a factorial_algorithm #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
43 changes: 43 additions & 0 deletions Algorithms/factorial_template/factorial/factorial.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="factorial" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/factorial" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/factorial" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
4 changes: 4 additions & 0 deletions Algorithms/factorial_template/factorial/factorial.depend
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# depslib dependency file v1.0
1575527076 source:c:\users\kavya goyal\desktop\a2oj\factorial\main.cpp
<iostream>

10 changes: 10 additions & 0 deletions Algorithms/factorial_template/factorial/factorial.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="317" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
27 changes: 27 additions & 0 deletions Algorithms/factorial_template/factorial/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>

using namespace std;

int main()
{ //FACTORIAL
//no of which factorial s to be found out,
int n;
cin>>n;

// We can also do this without the array, using the for loop only also
int arr[n];
long long int fac = 1;

for(int i=1; i<=n; i++){
fac= fac*(i);
arr[i-1] = fac;
}
if(n==0){
arr[n-1] = 1;
}
//An array of all the numbers till then would be created.
//To access the factorial of the number
cout<<arr[n-1];
return 0;
}

Binary file not shown.