C
C#17mo ago
osmorredor

❔ Trying to build a Windows Form that displays factorial equation

I'm have built a simple form that displays the result of a factorial equation with N input (pictured attached). However, Id like to take it a step further and input the equation within the calculation. Example: 4! = 4 * 3 * 2 * 1 = 24 I don't know if that's possible, but I think it could be a pretty cool addition. Is becoming troublesome since I cannot add items within the line as .Add adds to a list by jumps... Dunno if what I want can be achieved 🙂
3 Replies
ero
ero17mo ago
of course you can add things within the line
MODiX
MODiX17mo ago
Ero#1111
REPL Result: Success
int value = 5, result = 1;
string output = $"{value}! = ";

for (int i = value; i >= 2; i--)
{
result *= i;
output += $"{i}";

if (i > 2)
output += " * ";
}

output += $" * 1 = {result}";

output
int value = 5, result = 1;
string output = $"{value}! = ";

for (int i = value; i >= 2; i--)
{
result *= i;
output += $"{i}";

if (i > 2)
output += " * ";
}

output += $" * 1 = {result}";

output
Result: string
5! = 5 * 4 * 3 * 2 * 1 = 120
5! = 5 * 4 * 3 * 2 * 1 = 120
Compile: 581.238ms | Execution: 64.359ms | React with ❌ to remove this embed.
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity. Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts