Skip to content
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
27 changes: 21 additions & 6 deletions week-1/day-3/exercise-1/FactorialApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
namespace FactorialApp
using System;

namespace FactorialApp
{
public class Program
{
public static void Main()
{
Console.WriteLine("Hello, World!");
Console.Write("Enter a number: ");
int number = int.Parse(Console.ReadLine());

long factorial = CalculateFactorial(number);
int userInput = Convert.ToInt32(Console.ReadLine());

Console.WriteLine($"The factorial of {number} is: {factorial}");
if (userInput < 0)
{
Console.WriteLine("Factorial is not valid for negative numbers.");
}
else
{
long result = CalculateFactorial(userInput);
Console.WriteLine($"Factorial of {userInput} is {result}");
}
}

public static long CalculateFactorial(int number)
{
throw new NotImplementedException();
// throw new NotImplementedException();
int factorial = 1;
for (int i = 1; i <= number; i++)
{
factorial *= i;
}
return factorial;
}
}
}
2 changes: 1 addition & 1 deletion week-1/day-3/exercise-2/ShortesPathAlgorithm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public int[] DijkstraShortestPath(int source)
visited[i] = false;
}

distances[source] = int.MinValue;
distances[source] = 0;

for (int count = 0; count < vertices - 1; count++)
{
Expand Down