Answer the question
In order to leave comments, you need to log in
Cast. How to convert BigIntenger to String and count the number of characters?
Hello !
The question is how to convert a BigIntenger to a String and count the number of characters in it?
The program calculates the factorial of an arbitrary number, DOES NOT display the result (number) on the screen, since it may be too large, but displays how many characters (digits) are in this number.
This is easy to do in Python.
import math
while True:
x = int(input("Введите число для вычисления факториала: "))
fc = math.factorial(x)
print("Факториал числа",x, "Цифр в числе - ", len(str(fc)))
using System.Numerics;
Console.WriteLine("Hello, World!");
BigInteger n = 4; // количество циклов в факториале
BigInteger factorial = 1; // значение факториала
for (BigInteger i = 2; i <= n; i++)
{
factorial *= i;
}
Console.WriteLine(factorial.ToString()); // Преобразовать число в строку
Console.WriteLine(factorial.GetBitLength()); // Подсчитать количество сиволов в строке
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question