Skip to content

Instantly share code, notes, and snippets.

@unilecs
Created November 20, 2017 06:11
Show Gist options
  • Save unilecs/dfcaaf90207f1f0f238b52911d47659b to your computer and use it in GitHub Desktop.
Save unilecs/dfcaaf90207f1f0f238b52911d47659b to your computer and use it in GitHub Desktop.
Разворот числа без циклов
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