Esempio n. 1
0
<?php

$l_index = 0;
$l_s = 0;
$l_f = 0;
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
$conn = new PDO('mysql:host=localhost;dbname=collatz', 'root', '1234');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$statement = $conn->prepare('drop table if exists collatz');
$statement->execute();
$statement = $conn->prepare('create table if not exists collatz (n int primary key, rowIndex int, columnIndex int, successor int, iterations int, formula varchar(1000), formulaName varchar(1000))');
$statement->execute();
for ($i = 1; $i <= 10; ++$i) {
    insertCollatzes(40);
}
while (false) {
    $statement = $conn->prepare('select n from collatz where iterations = 0 and n <> 1 limit 1');
    $statement->execute();
    $result = $statement->setFetchMode(PDO::FETCH_ASSOC);
    $rows = $statement->fetchAll();
    if (count($rows) == 0) {
        break;
    }
    updateIterations($rows[0]['n'], 0);
}
//    $maxCollatz = maxCollatz();
for ($i = 1; $i <= 400; $i += 2) {
    echo $i . ": ";
    foreach (getCollatz($i, array()) as $current) {
Esempio n. 2
0
<?php

$l_index = 0;
$l_s = 0;
$l_f = 0;
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
$conn = new PDO('mysql:host=localhost;dbname=collatz', 'root', '1234');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
insertCollatzes(1001);
for ($i = 1; $i < 100; $i += 2) {
    $catIndices = getCatIndices($i);
    echo $i . ": " . $catIndices[0] . ", " . $catIndices[1];
    echo "<br>";
}
/*function load_fc_shapes()
{
    global $conn;
    $statement = $conn->prepare('
        select fc_shape.id as id, x, y, fc_shape_type.name as shapeType, title, text
        from fc_shape
        join book
          on fc_shape.book_id = book.id
        join user
           on book.user_id = :user_id
        join fc_shape_type
          on fc_shape.fc_shape_type_id = fc_shape_type.id
        where
          book_id = (select max(book.id) from book where book.name = :book_name)');
    $statement->bindParam(':user_id', $_SESSION['user_id']);