c# doubts | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

c# doubts

namespace SoloLearn { class Program { static int Fact(int num) { if (num == 1) { return 1; } return num * Fact(num - 1); } static void Main(string[] args) { int n= Convert.ToInt32(Console.Read()); Console.WriteLine(Fact(n)); } } } when i enter any number as input.. it always returning the output as 0....why this happening??? HELP MEEEEEE

11th Feb 2018, 6:18 AM
Vishal R
Vishal R - avatar
1 ответ
+ 1
There is something wrong with your input line. int n = Convert.ToInt32(Console.ReadLine()); This one works.
11th Feb 2018, 7:36 AM
Paul
Paul - avatar