Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
38
Task/Humble-numbers/V-(Vlang)/humble-numbers.v
Normal file
38
Task/Humble-numbers/V-(Vlang)/humble-numbers.v
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
fn is_humble(i int) bool {
|
||||
if i <= 1 {return true}
|
||||
if i % 2 == 0 {return is_humble(i / 2)}
|
||||
if i % 3 == 0 {return is_humble(i / 3)}
|
||||
if i % 5 == 0 {return is_humble(i / 5)}
|
||||
if i % 7 == 0 {return is_humble(i / 7)}
|
||||
return false
|
||||
}
|
||||
|
||||
fn main() {
|
||||
limit := max_i16
|
||||
mut humble := map[int]int{}
|
||||
mut count, mut len, mut total, mut num := 0, 0, 0, 1
|
||||
mut str :=""
|
||||
|
||||
for count < limit {
|
||||
if is_humble(num) == true {
|
||||
str = num.str()
|
||||
len = str.len
|
||||
humble[len]++
|
||||
if count < 50 {print("${num} ")}
|
||||
count++
|
||||
}
|
||||
num++
|
||||
}
|
||||
println("\n")
|
||||
|
||||
println("Of the first ${count} humble numbers:")
|
||||
num = 1
|
||||
for num < humble.len - 1 {
|
||||
if num in humble {
|
||||
total = humble[num]
|
||||
println("${total:5} have ${num:2} digits")
|
||||
num++
|
||||
}
|
||||
else {break}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue