Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
|
|
@ -1,20 +1,29 @@
|
|||
val .perfectsquare = fn(.n) (.n ^/ 2) div 1
|
||||
val perfectsquare = fn n: (n ^/ 2) div 1
|
||||
|
||||
val .israre = fn(.n) {
|
||||
val .r = reverse(.n)
|
||||
if .n == .r: return false
|
||||
val .sum = .n + .r
|
||||
val .diff = .n - .r
|
||||
.diff > 0 and .perfectsquare(.sum) and .perfectsquare(.diff)
|
||||
val israre = fn(n) {
|
||||
val r = reverse(n)
|
||||
if n == r: return false
|
||||
val sum = n + r
|
||||
val diff = n - r
|
||||
diff > 0 and perfectsquare(sum) and perfectsquare(diff)
|
||||
}
|
||||
|
||||
val .findfirst = fn(.max) {
|
||||
for[=[]] .i = 0; len(_for) < .max; .i += 1 {
|
||||
if .israre(.i) {
|
||||
_for ~= [.i]
|
||||
val findfirst = fn(mx) {
|
||||
for[=[]] i = 0; len(_for) < mx; i += 1 {
|
||||
if israre(i) {
|
||||
_for ~= [i]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val findandprint = impure fn(mx) {
|
||||
for[cnt=0] i = 0; cnt < mx ; i += 1 {
|
||||
if israre(i) {
|
||||
writeln "\n rare ", i, " "
|
||||
cnt += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# if you have the time...
|
||||
writeln "the first 5 rare numbers: ", .findfirst(5)
|
||||
writeln "the first 5 rare numbers: ", findfirst(5)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue