Skip to content

Instantly share code, notes, and snippets.

@xximjasonxx
Created June 11, 2024 18:13
Show Gist options
  • Save xximjasonxx/bdf125926dc7972e0b953e6a355ce89d to your computer and use it in GitHub Desktop.
Save xximjasonxx/bdf125926dc7972e0b953e6a355ce89d to your computer and use it in GitHub Desktop.
using System.ComponentModel;
using Microsoft.SemanticKernel;
namespace FactorialAdder.Plugins
{
public sealed class MathPlugin
{
[KernelFunction("factorial"), Description("Calculates the factorial of a number")]
public static int Factorial(
[Description("The number to get the factorial of")]int number)
{
int result = 1;
while (number > 1)
{
result *= number--;
}
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment