Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
44
Task/Deceptive-numbers/Forth/deceptive-numbers.fth
Normal file
44
Task/Deceptive-numbers/Forth/deceptive-numbers.fth
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
: modpow { c b a -- a^b mod c }
|
||||
c 1 = if 0 exit then
|
||||
1
|
||||
a c mod to a
|
||||
begin
|
||||
b 0>
|
||||
while
|
||||
b 1 and 1 = if
|
||||
a * c mod
|
||||
then
|
||||
a a * c mod to a
|
||||
b 2/ to b
|
||||
repeat ;
|
||||
|
||||
: deceptive? ( n -- ? )
|
||||
dup 2 mod 0= if drop false exit then
|
||||
dup 3 mod 0= if drop false exit then
|
||||
dup 5 mod 0= if drop false exit then
|
||||
dup dup 1- 10 modpow 1 <> if drop false exit then
|
||||
7 begin
|
||||
2dup dup * >
|
||||
while
|
||||
2dup mod 0= if 2drop true exit then
|
||||
4 +
|
||||
2dup mod 0= if 2drop true exit then
|
||||
2 +
|
||||
repeat
|
||||
2drop false ;
|
||||
|
||||
: main ( -- )
|
||||
0 7 begin
|
||||
over 100 <
|
||||
while
|
||||
dup deceptive? if
|
||||
dup 6 .r
|
||||
swap 1+ swap
|
||||
over 10 mod 0= if cr else space then
|
||||
then
|
||||
1+
|
||||
repeat
|
||||
2drop ;
|
||||
|
||||
main
|
||||
bye
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
val isPrime = fn(i) {
|
||||
i == 2 or i > 2 and
|
||||
not any(fn x: i div x, pseries(2 .. i ^/ 2))
|
||||
not any(series(2 .. i ^/ 2, asconly=true), by=fn x:i div x)
|
||||
}
|
||||
|
||||
var nums = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue