Created
November 20, 2017 06:11
-
-
Save unilecs/dfcaaf90207f1f0f238b52911d47659b to your computer and use it in GitHub Desktop.
Разворот числа без циклов
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Program | |
{ | |
public static double ReverseNumber(double num, double i) { | |
double div = System.Math.Floor(num / 10); | |
double reverseNum = i * 10 + num % 10; | |
return (num == 0) ? i : ReverseNumber(div, reverseNum); | |
} | |
public static void Main() | |
{ | |
Console.WriteLine("UniLecs"); | |
Console.WriteLine(ReverseNumber(12345, 0)); | |
Console.WriteLine(ReverseNumber(12000345, 0)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment