Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Ludic-numbers/PowerShell/ludic-numbers-1.psh
Normal file
18
Task/Ludic-numbers/PowerShell/ludic-numbers-1.psh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Start with a pool large enough to meet the requirements
|
||||
$Pool = [System.Collections.ArrayList]( 2..22000 )
|
||||
|
||||
# Start with 1, because it's grandfathered in
|
||||
$Ludic = @( 1 )
|
||||
|
||||
# While the size of the pool is still larger than the next Ludic number...
|
||||
While ( $Pool.Count -gt $Pool[0] )
|
||||
{
|
||||
# Add the next Ludic number to the list
|
||||
$Ludic += $Pool[0]
|
||||
|
||||
# Remove from the pool all entries whose index is a multiple of the next Ludic number
|
||||
[math]::Truncate( ( $Pool.Count - 1 )/ $Pool[0])..0 | ForEach { $Pool.RemoveAt( $_ * $Pool[0] ) }
|
||||
}
|
||||
|
||||
# Add the rest of the numbers in the pool to the list of Ludic numbers
|
||||
$Ludic += $Pool.ToArray()
|
||||
15
Task/Ludic-numbers/PowerShell/ludic-numbers-2.psh
Normal file
15
Task/Ludic-numbers/PowerShell/ludic-numbers-2.psh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Display the first 25 Ludic numbers
|
||||
$Ludic[0..24] -join ", "
|
||||
''
|
||||
|
||||
# Display the count of all Ludic numbers under 1000
|
||||
$Ludic.Where{ $_ -le 1000 }.Count
|
||||
''
|
||||
|
||||
# Display the 2000th through the 2005th Ludic number
|
||||
$Ludic[1999..2004] -join ", "
|
||||
''
|
||||
|
||||
# Display all Ludic triplets less than 250
|
||||
$TripletStart = $Ludic.Where{ $_ -lt 244 -and ( $_ + 2 ) -in $Ludic -and ( $_ + 6 ) -in $Ludic }
|
||||
$TripletStart.ForEach{ $_, ( $_ + 2 ), ( $_ + 6 ) -join ", " }
|
||||
Loading…
Add table
Add a link
Reference in a new issue