Name
Name
CC#
Created by Name on 4/21/2023 in #help
❔ How to make this program into GUI application?
171 replies
CC#
Created by Name on 4/1/2023 in #help
❔ How to generate all possible multiplications of a given number?
I have this code:
using System;

class GFG
{


static void findCombinationsUtil(int[] arr, int index, int num, int reducedNum)
{

if (reducedNum < 0)
return;


if (reducedNum == 0)
{
for (int i = 0; i < index; i++)
Console.Write(arr[i] + " ");
Console.WriteLine();
return;
}


int prev = (index == 0) ?
1 : arr[index - 1];


for (int k = prev; k <= num; k++)
{

arr[index] = k;


findCombinationsUtil(arr, index + 1, num, reducedNum - k);
}
}


static void findCombinations(int n)
{

int[] arr = new int[n];


findCombinationsUtil(arr, 0, n, n);
}


static public void Main()
{

Console.WriteLine("Enter number: ");
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Disintegration is: " + n);
findCombinations(n);
}
}
using System;

class GFG
{


static void findCombinationsUtil(int[] arr, int index, int num, int reducedNum)
{

if (reducedNum < 0)
return;


if (reducedNum == 0)
{
for (int i = 0; i < index; i++)
Console.Write(arr[i] + " ");
Console.WriteLine();
return;
}


int prev = (index == 0) ?
1 : arr[index - 1];


for (int k = prev; k <= num; k++)
{

arr[index] = k;


findCombinationsUtil(arr, index + 1, num, reducedNum - k);
}
}


static void findCombinations(int n)
{

int[] arr = new int[n];


findCombinationsUtil(arr, 0, n, n);
}


static public void Main()
{

Console.WriteLine("Enter number: ");
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Disintegration is: " + n);
findCombinations(n);
}
}
And what it does is it generates all the sums of a given number. Here's how it works: Input: 3 Output: 1 1 1 2 1 So I enter any number I want and it generates all possible sums of that number. I want to do the same but with multiplications. Anyone know how?
41 replies