From df04d9454332dc0ea916a6dbe6da2b71d7ae9782 Mon Sep 17 00:00:00 2001 From: Vysor Date: Tue, 23 Apr 2019 00:53:56 +1000 Subject: [PATCH] Some directories had a capital in their name [fixed]. Added a recursive factorial algorithm. (#763) * Renaming directories * Adding a recursive factorial algorithm --- {Graphs => graphs}/BFS.py | 0 {Graphs => graphs}/DFS.py | 0 .../Directed and Undirected (Weighted) Graph.py | 0 {Graphs => graphs}/a_star.py | 0 {Graphs => graphs}/articulation_points.py | 0 {Graphs => graphs}/basic_graphs.py | 0 {Graphs => graphs}/bellman_ford.py | 0 {Graphs => graphs}/breadth_first_search.py | 0 {Graphs => graphs}/check_bipartite_graph_bfs.py | 0 {Graphs => graphs}/depth_first_search.py | 0 {Graphs => graphs}/dijkstra.py | 0 {Graphs => graphs}/dijkstra_2.py | 0 {Graphs => graphs}/dijkstra_algorithm.py | 0 {Graphs => graphs}/even_tree.py | 0 {Graphs => graphs}/finding_bridges.py | 0 {Graphs => graphs}/floyd_warshall.py | 0 {Graphs => graphs}/graph.py | 0 {Graphs => graphs}/graph_list.py | 0 {Graphs => graphs}/graph_matrix.py | 0 {Graphs => graphs}/kahns_algorithm_long.py | 0 {Graphs => graphs}/kahns_algorithm_topo.py | 0 {Graphs => graphs}/minimum_spanning_tree_kruskal.py | 0 {Graphs => graphs}/minimum_spanning_tree_prims.py | 0 {Graphs => graphs}/multi_hueristic_astar.py | 0 {Graphs => graphs}/scc_kosaraju.py | 0 {Graphs => graphs}/tarjans_scc.py | 0 {Maths => maths}/3n+1.py | 0 {Maths => maths}/FindMax.py | 0 {Maths => maths}/FindMin.py | 0 {Maths => maths}/abs.py | 0 {Maths => maths}/absMax.py | 0 {Maths => maths}/absMin.py | 0 {Maths => maths}/average.py | 0 {Maths => maths}/extended_euclidean_algorithm.py | 0 maths/factorial_recursive.py | 13 +++++++++++++ {Maths => maths}/find_lcm.py | 0 36 files changed, 13 insertions(+) rename {Graphs => graphs}/BFS.py (100%) rename {Graphs => graphs}/DFS.py (100%) rename {Graphs => graphs}/Directed and Undirected (Weighted) Graph.py (100%) rename {Graphs => graphs}/a_star.py (100%) rename {Graphs => graphs}/articulation_points.py (100%) rename {Graphs => graphs}/basic_graphs.py (100%) rename {Graphs => graphs}/bellman_ford.py (100%) rename {Graphs => graphs}/breadth_first_search.py (100%) rename {Graphs => graphs}/check_bipartite_graph_bfs.py (100%) rename {Graphs => graphs}/depth_first_search.py (100%) rename {Graphs => graphs}/dijkstra.py (100%) rename {Graphs => graphs}/dijkstra_2.py (100%) rename {Graphs => graphs}/dijkstra_algorithm.py (100%) rename {Graphs => graphs}/even_tree.py (100%) rename {Graphs => graphs}/finding_bridges.py (100%) rename {Graphs => graphs}/floyd_warshall.py (100%) rename {Graphs => graphs}/graph.py (100%) rename {Graphs => graphs}/graph_list.py (100%) rename {Graphs => graphs}/graph_matrix.py (100%) rename {Graphs => graphs}/kahns_algorithm_long.py (100%) rename {Graphs => graphs}/kahns_algorithm_topo.py (100%) rename {Graphs => graphs}/minimum_spanning_tree_kruskal.py (100%) rename {Graphs => graphs}/minimum_spanning_tree_prims.py (100%) rename {Graphs => graphs}/multi_hueristic_astar.py (100%) rename {Graphs => graphs}/scc_kosaraju.py (100%) rename {Graphs => graphs}/tarjans_scc.py (100%) rename {Maths => maths}/3n+1.py (100%) rename {Maths => maths}/FindMax.py (100%) rename {Maths => maths}/FindMin.py (100%) rename {Maths => maths}/abs.py (100%) rename {Maths => maths}/absMax.py (100%) rename {Maths => maths}/absMin.py (100%) rename {Maths => maths}/average.py (100%) rename {Maths => maths}/extended_euclidean_algorithm.py (100%) create mode 100644 maths/factorial_recursive.py rename {Maths => maths}/find_lcm.py (100%) diff --git a/Graphs/BFS.py b/graphs/BFS.py similarity index 100% rename from Graphs/BFS.py rename to graphs/BFS.py diff --git a/Graphs/DFS.py b/graphs/DFS.py similarity index 100% rename from Graphs/DFS.py rename to graphs/DFS.py diff --git a/Graphs/Directed and Undirected (Weighted) Graph.py b/graphs/Directed and Undirected (Weighted) Graph.py similarity index 100% rename from Graphs/Directed and Undirected (Weighted) Graph.py rename to graphs/Directed and Undirected (Weighted) Graph.py diff --git a/Graphs/a_star.py b/graphs/a_star.py similarity index 100% rename from Graphs/a_star.py rename to graphs/a_star.py diff --git a/Graphs/articulation_points.py b/graphs/articulation_points.py similarity index 100% rename from Graphs/articulation_points.py rename to graphs/articulation_points.py diff --git a/Graphs/basic_graphs.py b/graphs/basic_graphs.py similarity index 100% rename from Graphs/basic_graphs.py rename to graphs/basic_graphs.py diff --git a/Graphs/bellman_ford.py b/graphs/bellman_ford.py similarity index 100% rename from Graphs/bellman_ford.py rename to graphs/bellman_ford.py diff --git a/Graphs/breadth_first_search.py b/graphs/breadth_first_search.py similarity index 100% rename from Graphs/breadth_first_search.py rename to graphs/breadth_first_search.py diff --git a/Graphs/check_bipartite_graph_bfs.py b/graphs/check_bipartite_graph_bfs.py similarity index 100% rename from Graphs/check_bipartite_graph_bfs.py rename to graphs/check_bipartite_graph_bfs.py diff --git a/Graphs/depth_first_search.py b/graphs/depth_first_search.py similarity index 100% rename from Graphs/depth_first_search.py rename to graphs/depth_first_search.py diff --git a/Graphs/dijkstra.py b/graphs/dijkstra.py similarity index 100% rename from Graphs/dijkstra.py rename to graphs/dijkstra.py diff --git a/Graphs/dijkstra_2.py b/graphs/dijkstra_2.py similarity index 100% rename from Graphs/dijkstra_2.py rename to graphs/dijkstra_2.py diff --git a/Graphs/dijkstra_algorithm.py b/graphs/dijkstra_algorithm.py similarity index 100% rename from Graphs/dijkstra_algorithm.py rename to graphs/dijkstra_algorithm.py diff --git a/Graphs/even_tree.py b/graphs/even_tree.py similarity index 100% rename from Graphs/even_tree.py rename to graphs/even_tree.py diff --git a/Graphs/finding_bridges.py b/graphs/finding_bridges.py similarity index 100% rename from Graphs/finding_bridges.py rename to graphs/finding_bridges.py diff --git a/Graphs/floyd_warshall.py b/graphs/floyd_warshall.py similarity index 100% rename from Graphs/floyd_warshall.py rename to graphs/floyd_warshall.py diff --git a/Graphs/graph.py b/graphs/graph.py similarity index 100% rename from Graphs/graph.py rename to graphs/graph.py diff --git a/Graphs/graph_list.py b/graphs/graph_list.py similarity index 100% rename from Graphs/graph_list.py rename to graphs/graph_list.py diff --git a/Graphs/graph_matrix.py b/graphs/graph_matrix.py similarity index 100% rename from Graphs/graph_matrix.py rename to graphs/graph_matrix.py diff --git a/Graphs/kahns_algorithm_long.py b/graphs/kahns_algorithm_long.py similarity index 100% rename from Graphs/kahns_algorithm_long.py rename to graphs/kahns_algorithm_long.py diff --git a/Graphs/kahns_algorithm_topo.py b/graphs/kahns_algorithm_topo.py similarity index 100% rename from Graphs/kahns_algorithm_topo.py rename to graphs/kahns_algorithm_topo.py diff --git a/Graphs/minimum_spanning_tree_kruskal.py b/graphs/minimum_spanning_tree_kruskal.py similarity index 100% rename from Graphs/minimum_spanning_tree_kruskal.py rename to graphs/minimum_spanning_tree_kruskal.py diff --git a/Graphs/minimum_spanning_tree_prims.py b/graphs/minimum_spanning_tree_prims.py similarity index 100% rename from Graphs/minimum_spanning_tree_prims.py rename to graphs/minimum_spanning_tree_prims.py diff --git a/Graphs/multi_hueristic_astar.py b/graphs/multi_hueristic_astar.py similarity index 100% rename from Graphs/multi_hueristic_astar.py rename to graphs/multi_hueristic_astar.py diff --git a/Graphs/scc_kosaraju.py b/graphs/scc_kosaraju.py similarity index 100% rename from Graphs/scc_kosaraju.py rename to graphs/scc_kosaraju.py diff --git a/Graphs/tarjans_scc.py b/graphs/tarjans_scc.py similarity index 100% rename from Graphs/tarjans_scc.py rename to graphs/tarjans_scc.py diff --git a/Maths/3n+1.py b/maths/3n+1.py similarity index 100% rename from Maths/3n+1.py rename to maths/3n+1.py diff --git a/Maths/FindMax.py b/maths/FindMax.py similarity index 100% rename from Maths/FindMax.py rename to maths/FindMax.py diff --git a/Maths/FindMin.py b/maths/FindMin.py similarity index 100% rename from Maths/FindMin.py rename to maths/FindMin.py diff --git a/Maths/abs.py b/maths/abs.py similarity index 100% rename from Maths/abs.py rename to maths/abs.py diff --git a/Maths/absMax.py b/maths/absMax.py similarity index 100% rename from Maths/absMax.py rename to maths/absMax.py diff --git a/Maths/absMin.py b/maths/absMin.py similarity index 100% rename from Maths/absMin.py rename to maths/absMin.py diff --git a/Maths/average.py b/maths/average.py similarity index 100% rename from Maths/average.py rename to maths/average.py diff --git a/Maths/extended_euclidean_algorithm.py b/maths/extended_euclidean_algorithm.py similarity index 100% rename from Maths/extended_euclidean_algorithm.py rename to maths/extended_euclidean_algorithm.py diff --git a/maths/factorial_recursive.py b/maths/factorial_recursive.py new file mode 100644 index 000000000..41391a271 --- /dev/null +++ b/maths/factorial_recursive.py @@ -0,0 +1,13 @@ +def fact(n): + """ + Return 1, if n is 1 or below, + otherwise, return n * fact(n-1). + """ + return 1 if n <= 1 else n * fact(n-1) + +""" +Shown factorial for i, +where i ranges from 1 to 20. +""" +for i in range(1,21): + print(i, ": ", fact(i), sep='') diff --git a/Maths/find_lcm.py b/maths/find_lcm.py similarity index 100% rename from Maths/find_lcm.py rename to maths/find_lcm.py