Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ExtraExercise_TopInteger
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int divider = int.Parse(Console.ReadLine());
- double result = DivisibleFactorial(n, divider);
- Console.WriteLine($"{result:f2}");
- }
- private static int DivisibleFactorial(int n, int divider)
- {
- int n1 = n;
- int sum = 0;
- while (n1 != 0)
- {
- int factorial = 1;
- int currentNumber = n1 % 10;
- n1 /= 10;
- for (int i = 1; i <= currentNumber; i++)
- {
- factorial *= i;
- }
- sum += factorial;
- }
- return sum /= divider;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment