$text = "Это мой текст. Да, вот такой.";
$text_v_kavychkah = "'" . $text . "'"; // точка означает склеивание строк
// или
$text_v_kavychkah = '\'' . $text . '\''; // только одинарные кавычки
// или
$text_v_kavychkah = "'$text'"; // в двойных кавычках подставится значение переменной
// или
$text_v_kavychkah = sprintf("'%s'", $text); // текстовое значение подставится вместо %s
function fibRange( from, to) {
if( isNaN(from) || isNaN(to) || from < 2 || from > to) {
throw "Bad argument(s)";
}
var root5 = Math.sqrt(5), phi = (1 + root5)/2, logPhi = Math.log(phi);
var nFrom = Math.ceil( Math.log((from - 0.5) * root5) / logPhi);
var nTo = Math.floor( Math.log((to+0.5) * root5) / logPhi);
function nthFib(n) {
return Math.round( (Math.pow(phi, n) - Math.pow( -phi, -n)) / (2 * phi - 1));
}
var a = nthFib(nFrom);
var result = [a];
if( nFrom === nTo) return result;
var i = nFrom + 1;
var b = nthFib(i);
while( i <= nTo) {
result.push(b);
b = a + b;
a = b - a;
i++;
}
return result;
}
fibRange(10,377)
/*
13,21,34,55,89,144,233,377
*/
function primes(n) {
var i, j, isPrime = Array(n), result= [];
for(i=2; i<n; i++) isPrime[i] = true;
for(i=2; i * i <= n; i++) {
if( isPrime[i]) {
for(j = i * i; j <= n; j += i) isPrime[j] = false;
}
}
for(i=2; i<n; i++) {
if(isPrime[i] === true) result.push(i);
}
return result;
}
ooooooooooo
||-->
ooooooooooo
||-->
import numpy as np
def noZeros(a):
arr = np.array(a)
rows = arr[ ~np.all(arr == 0, axis = 1)]
colsTrue = ~np.all(rows == 0, axis = 0)
return rows[:, colsTrue == True]
a = [
[0,4,0,1,0],
[0,0,2,3,0],
[0,0,3,1,0],
[0,0,0,0,0],
]
noZeros(a)
array([[4, 0, 1],
[0, 2, 3],
[0, 3, 1]])
© Вася Пупкин <?php echo date('Y'); ?>
v
.