(print (map (fn [a] (/ a 2)) (filter even? (range 1 11))))
(1..10).select{|x| x % 2 == 0}.map{|x| puts x / 2}
for i in {1..10}
do
if [ "$(expr $i / 2)" -eq 0 ]; then
echo `expr $i / 2`
if
done
package main
import "fmt"
func main() {
a := [...]int {1, 2, 3, 4, 5, 6, 7 ,8, 9, 10}
for i :=range a {
if a[i] % 2 == 0 {
fmt.Println(a[i] / 2)
Range(1,11).filter(_%2 == 0).map(_/2).map(println)
The following is the description of first problem we need to solve, try finish it before Friday. There's no rule to complete the issue, you can use either languages with either way. Clean code is also not a requirement. In another way, there's no "Jiecao" to finish that.
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.
Ctrl+C | copy current line (if no selection) |
Ctrl+X | cut current line (if no selection) |
Ctrl+⇧+K | delete line |
Ctrl+↩ | insert line after |
For I get this error when I try to use ree-1.8.7 to install chef which depends on rest-client.
~> gem install rest-client
ERROR: Error installing rest-client:
mime-types requires Ruby version >= 1.9.2.
My question is that does rest-client get rid of supporting 1.8.7 completely? If not, how could I make it happen under ruby 1.8.7, by downgrading the version?