let s be Nat; ex n being Nat st
( Sum (digits (n,10)) = s & s divides n )
per cases
( s = 0 or s > 0 )
;
suppose A2:
s > 0
;
ex n being Nat st
( Sum (digits (n,10)) = s & s divides n )set a = 2
|-count s;
set b = 5
|-count s;
A3:
( 2
|^ (2 |-count s) divides s & 5
|^ (5 |-count s) divides s )
by A2, NAT_3:def 7;
A4:
2
|^ (2 |-count s),5
|^ (5 |-count s) are_coprime
by WSIERP_1:11, EULER_1:2, PEPIN:59;
then consider t being
Nat such that A5:
s = ((2 |^ (2 |-count s)) * (5 |^ (5 |-count s))) * t
by NAT_D:def 3, A3, PEPIN:4;
A6:
t divides s
by A5;
A7:
t <> 0
by A5, A2;
then A8:
Euler t <> 0
;
deffunc H1()
-> set =
(s * (Euler t)) + 1;
defpred S1[
Nat,
object ]
means ( ( ex
l being
Nat st
( 1
<= l &
l <= s & $1
= l * (Euler t) ) & $2
= 1 ) or ( ( for
l being
Nat holds
( not 1
<= l or not
l <= s or not $1
= l * (Euler t) ) ) & $2
= 0 ) );
A9:
for
k being
Nat st
k in H1() holds
ex
x being
object st
S1[
k,
x]
proof
let k be
Nat;
( k in H1() implies ex x being object st S1[k,x] )
assume
k in H1()
;
ex x being object st S1[k,x]
end; consider d being
XFinSequence such that A12:
(
dom d = H1() & ( for
k being
Nat st
k in H1() holds
S1[
k,
d . k] ) )
from AFINSQ_1:sch 1(A9);
rng d c= NAT
then reconsider d =
d as
XFinSequence of
NAT by RELAT_1:def 19;
A14:
s >= 0 + 1
by A2, NAT_1:13;
then
1
* (Euler t) < (s * (Euler t)) + 1
by NAT_1:13, XREAL_1:64;
then A15:
1
* (Euler t) in Segm H1()
by NAT_1:44;
then A16:
d . (1 * (Euler t)) = 1
by A14, A12;
set o =
value (
d,10);
consider e being
XFinSequence of
NAT such that A17:
(
dom e = dom d & ( for
i being
Nat st
i in dom e holds
e . i = (d . i) * (10 |^ i) ) &
value (
d,10)
= Sum e )
by NUMERAL1:def 1;
e . (Euler t) = 1
* (10 |^ (Euler t))
by A17, A12, A15, A16;
then A18:
value (
d,10)
> 0
by A17, A12, A15, AFINSQ_2:61;
take n =
(10 |^ ((2 |-count s) + (5 |-count s))) * (value (d,10));
( Sum (digits (n,10)) = s & s divides n )
s * (Euler t) < (s * (Euler t)) + 1
by NAT_1:13;
then
s * (Euler t) in Segm H1()
by NAT_1:44;
then A19:
d . ((len d) - 1) <> 0
by A12, A14;
then A20:
digits (
(value (d,10)),10)
= d
by NUMBER11:5, A12, A19;
rng d c= {0,1}
then A22:
Sum d = 1
* (card (d " {1}))
by AFINSQ_2:68;
deffunc H2(
Nat)
-> set =
($1 + 1) * (Euler t);
consider f being
XFinSequence such that A23:
(
len f = s & ( for
k being
Nat st
k in s holds
f . k = H2(
k) ) )
from AFINSQ_1:sch 2();
A24:
rng f = d " {1}
f is
one-to-one
then
s,
d " {1} are_equipotent
by A23, A24, WELLORD2:def 4;
then A33:
card s = card (d " {1})
by CARD_1:5;
digits (
n,10)
= (((2 |-count s) + (5 |-count s)) --> 0) ^ (digits ((value (d,10)),10))
by Th55, A18;
hence Sum (digits (n,10)) =
(Sum (((2 |-count s) + (5 |-count s)) --> 0)) + (Sum (digits ((value (d,10)),10)))
by AFINSQ_2:55
.=
(((2 |-count s) + (5 |-count s)) * 0) + s
by AFINSQ_2:58, A20, A22, A33
.=
s
;
s divides n
10
= 5
* 2
;
then A34:
2
|^ (2 |-count s) divides 10
|^ (2 |-count s)
by NEWTON02:15, INT_1:def 3;
(2 |-count s) + 0 <= (2 |-count s) + (5 |-count s)
by XREAL_1:7;
then
10
|^ (2 |-count s) divides 10
|^ ((2 |-count s) + (5 |-count s))
by NEWTON:89;
then A35:
2
|^ (2 |-count s) divides 10
|^ ((2 |-count s) + (5 |-count s))
by A34, INT_2:9;
10
= 5
* 2
;
then A36:
5
|^ (5 |-count s) divides 10
|^ (5 |-count s)
by NEWTON02:15, INT_1:def 3;
0 + (5 |-count s) <= (2 |-count s) + (5 |-count s)
by XREAL_1:7;
then
10
|^ (5 |-count s) divides 10
|^ ((2 |-count s) + (5 |-count s))
by NEWTON:89;
then
5
|^ (5 |-count s) divides 10
|^ ((2 |-count s) + (5 |-count s))
by A36, INT_2:9;
then A37:
(2 |^ (2 |-count s)) * (5 |^ (5 |-count s)) divides 10
|^ ((2 |-count s) + (5 |-count s))
by A35, A4, PEPIN:4;
t divides value (
d,10)
proof
per cases
( t = 0 or t = 1 or t >= 1 + 1 )
by NAT_1:23;
suppose
t >= 1
+ 1
;
t divides value (d,10)then A38:
t > 1
by NAT_1:13;
A39:
2,
t are_coprime
5,
t are_coprime
then A44:
2
* 5,
t are_coprime
by INT_2:26, A39;
now for i being Nat st i in dom e holds
d . i = (e . i) mod tlet i be
Nat;
( i in dom e implies d . b1 = (e . b1) mod t )assume A45:
i in dom e
;
d . b1 = (e . b1) mod tper cases
( ex l being Nat st
( 1 <= l & l <= s & i = l * (Euler t) ) or for l being Nat holds
( not 1 <= l or not l <= s or not i = l * (Euler t) ) )
;
suppose
ex
l being
Nat st
( 1
<= l &
l <= s &
i = l * (Euler t) )
;
d . b1 = (e . b1) mod tthen consider l being
Nat such that A46:
( 1
<= l &
l <= s &
i = l * (Euler t) )
;
d . i = 1
by A45, A12, A17, A46;
then e . i =
1
* (10 |^ (l * (Euler t)))
by A46, A17, A45
.=
(10 |^ (Euler t)) |^ l
by NEWTON:9
;
then (e . i) mod t =
(((10 |^ (Euler t)) mod t) |^ l) mod t
by EULER_2:22
.=
(1 |^ l) mod t
by A44, A38, EULER_2:18
.=
1
by A38, NAT_D:14
;
hence
d . i = (e . i) mod t
by A45, A12, A17, A46;
verum end; end; end; then (Sum e) mod t =
s mod t
by A22, A33, NUMERAL2:17, A17
.=
0
by A6
;
hence
t divides value (
d,10)
by A17, A7, PEPIN:6;
verum end; end;
end; hence
s divides n
by NAT_3:1, A37, A5;
verum end; end;