Hello, I'm new to this forum, and im new as a Progammer,
I am studying at university, and there's a task I have given
To make a Recursion.
I need to input a number like - 123456
and it adds every number seperate, and like 1+2+3+4+5+6 = 21
And I have no Idea how do I seperate numbers if its together as one?
This is what I need to make.
And I have given a example from Recursion factorial - this code.
class Rekursija
{
static void Main(string[] args)
{ i= int.Parse(Console.ReadLine());
printText(i);
}
static void printText(int i)
{
Console.WriteLine(i); if (i > 0) { i--; printText(i);
} } }
I am studying at university, and there's a task I have given
To make a Recursion.
I need to input a number like - 123456
and it adds every number seperate, and like 1+2+3+4+5+6 = 21
And I have no Idea how do I seperate numbers if its together as one?
This is what I need to make.
And I have given a example from Recursion factorial - this code.
class Rekursija
{
static void Main(string[] args)
{ i= int.Parse(Console.ReadLine());
printText(i);
}
static void printText(int i)
{
Console.WriteLine(i); if (i > 0) { i--; printText(i);
} } }