Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
11
Task/Humble-numbers/Tcl/humble-numbers-1.tcl
Normal file
11
Task/Humble-numbers/Tcl/humble-numbers-1.tcl
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
proc humble? x {
|
||||
foreach f {2 3 5 7} {
|
||||
while {$x % $f == 0} {set x [expr {$x / $f}]}
|
||||
}
|
||||
return [expr {$x == 1}]
|
||||
}
|
||||
set t1 {}
|
||||
for {set i 1} {[llength $t1] < 50} {incr i} {
|
||||
if [humble? $i] {lappend t1 $i}
|
||||
}
|
||||
puts $t1
|
||||
12
Task/Humble-numbers/Tcl/humble-numbers-2.tcl
Normal file
12
Task/Humble-numbers/Tcl/humble-numbers-2.tcl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
proc task2 {nmax} {
|
||||
puts "Distribution of digit length for the first $nmax humble numbers"
|
||||
set nHumble 0
|
||||
for {set i 1} {$nHumble < $nmax} {incr i} {
|
||||
if {[humble? $i]} {
|
||||
incr nHumble
|
||||
incr N([string length $i])
|
||||
}
|
||||
}
|
||||
parray N
|
||||
}
|
||||
task2 4096
|
||||
Loading…
Add table
Add a link
Reference in a new issue