Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Super-d-numbers/Swift/super-d-numbers.swift
Normal file
33
Task/Super-d-numbers/Swift/super-d-numbers.swift
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import BigInt
|
||||
import Foundation
|
||||
|
||||
let rd = ["22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999"]
|
||||
|
||||
for d in 2...9 {
|
||||
print("First 10 super-\(d) numbers:")
|
||||
|
||||
var count = 0
|
||||
var n = BigInt(3)
|
||||
var k = BigInt(0)
|
||||
|
||||
while true {
|
||||
k = n.power(d)
|
||||
k *= BigInt(d)
|
||||
|
||||
if let _ = String(k).range(of: rd[d - 2]) {
|
||||
count += 1
|
||||
|
||||
print(n, terminator: " ")
|
||||
fflush(stdout)
|
||||
|
||||
guard count < 10 else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
n += 1
|
||||
}
|
||||
|
||||
print()
|
||||
print()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue