Dubai Off Plan Projects by top Dubai real estate developers. Find the latest info regarding project phases and discover the bets off plan properties in Dubai.
Dubai off plan properties are becoming the most popular real estate investment option for property seekers in Dubai. Visit us today to get the latest off plan info.
Dubai Off Plan Projects by top Dubai real estate developers. Find the latest info regarding project phases and discover the bets off plan properties in Dubai.
Dubai off plan properties are becoming the most popular real estate investment option for property seekers in Dubai. Visit us today to get the latest off plan info.
10. var count = 0;
for (var i=2 ; i<=10000 ; i = i+2){
var value = 9*i+4;
while(true){
value = calc(value);
if(value == 1){
break;
}
if(value == i){
count++;
break;
}
}
}
console.log(count);
function calc(val){
var result = 0;
if(val % 2 == 0){
result = val / 2;
}else{
result = 3 * val + 1;
}
return result;
}
javascriptの解答例
11. # ループしているかチェック
def is_loop(n)
# 最初は3をかけて1をたす
check = n * 3 + 1
# 1になるまで数字を変化させることを繰り返す
while check != 1 do
check = check.even? ? check / 2 : check * 3 + 1
return true if check == n
end
return false
end
# 2~10000まで、偶数についてチェックする
puts 2.step(10000, 2).count{|i|
is_loop(i)
}
Rubyでの解答例