forked from snev-25/Hacktoberfest2021--1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fact.cpp
67 lines (61 loc) · 1.24 KB
/
fact.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <bits/stdc++.h>
using namespace std;
// #define ll long long int
ll mult(int i)
{
vector<int> ans;
ll tp;
while(i>0)
{
tp = i%10;
i = (int)i/10;
ans.push_back(tp);
}
ll mul = 1;
for (ll j=0; j<ans.size();j++)
{
mul*=ans[j];
}
return mul;
}
void fun()
{
ll t;
// cin>>t;
t = 1;
while(t--)
{
ll x = 1000000-1;
// cin>>x;
string y = to_string(x);
if (x==0)
cout<<1;
else if (x<10)
cout<<(x);
else
{
int fct;
int fact[] = {1,2,6,24,120,720, 5040};
ll count = 0;
for(int i = 1; i<=x; i++)
{
int flag=0;
string dd = to_string(i);
for (auto &ch: dd)
if (&ch == "0")
{
flag=1;
break;
}
if (flag == 0)
{
ll mul = mult(i);
fct = fact[dd.length() -1];
if (mul>=fct)
count++;
}
}
cout<<(count);
}
}
}