-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspiral.helix.area.prime.php
422 lines (381 loc) · 12 KB
/
spiral.helix.area.prime.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
<?php
/*********************************************************************************************
* Prime Vector Codex Source Code.
* Prime number vectorial matrix and vectorial graphic table.
* *******************************************************************************************
* This file demonstrates the rich information that can be included in
* *******************************************************************************************
* The above formula, the prime numbers in numbers plane
* Ax, Ay or Az. Results obtained from the above formula,
* which will be advantageous to use the unit automatically
* shows the analytical plane. Vector in the first series
* of the formula, primes numbers say bid welcome to us.
*********************************************************************************************
* @author Ferdi Tekin <[email protected]>
* @version 1.0
* @package Release
* @sourcecode Show
* @sourceplace Bottom
* @primaryrelation Think Vector
* @primaryplace Think Vector https://github.com/ThinkVector/VECTOR
* @date 27.11.2014
* @time 21.18
*********************************************************************************************
*/
//****************************
//Time exucution for algoritm start time
//****************************
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
//****************************
function is_prime($number)
{
if ($number < 0) $number *= -1 ;
if ($number > 7) ;
else if ( $number == 1 ) {
return true;
}
else if ( $number == 2 ) {
return false;
}
else if ( $number == 3 ) {
return true;
}
else if ( $number == 5 ) {
return true;
}
else if ( $number == 7 ) {
return true;
}
// number count total if division by 2, 3, 4, 5, 6, 7, 8, 9, 10
$number2 = array_map('intval', str_split($number));
$ncountfor2 = 0;
$ncountfor3 = 0;
$ncountfor5 = 0;
$ncountfor7 = 0;
//$ncountfor7_left = 0;
//$ncountfor7_right = "";
$ncountfor9 = 0;
foreach($number2 as $key => $value )
{
$ncountfor3 += $value;
//$ncountfor7_right .= $number2[($key + 1)].$ncountfor7_right;
}
$ncountfor5 = $ncountfor2 = $number2[$key];
//$ncountfor7_right = $number2[0];
//$ncountfor7 = $ncountfor7_right - ( $ncountfor7_left * 2 );
if( ( $ncountfor5 % 5 ) == 0 || ( $ncountfor2 % 2 ) == 0 )
{
return false;
}
else if( ($ncountfor3 % 3) == 0 )
{
return false;
}
else if( ($ncountfor3 % 9) == 0 )
{
return false;
}
//else if( ($ncountfor7 % 7) == 0 && $ncountfor7 > 7)
//{
// return false;
//}
// square root algorithm speeds up testing of bigger prime numbers
$x = sqrt($number);
$x = floor($x);
for ( $i = 2 ; $i <= $x ; ++$i ) {
if ( $number % $i == 0 ) {
break;
}
}
if( $x == $i-1 ) {
return true;
} else {
return false;
}
}
function rand_color() {
return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
}
$areax = array (
1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1
);
$XAREA = array (
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0
);
$superb = 0;
$end = 36;
$begin = 0;
$beginrange = $begin;
$endcount = 0;
$jarray = 3; // first 3 vector shows
$visualchecked = "checked";
//*********************
//*Vector Tables Value
//*********************
$XXA = 60;
$YYA = 0;
$ZZA = 0;
//*********************
//*********************
if (isset($_POST["axvalue"]))
{
for($i = 0; $i < $XXA; $i++)
{
$areax[$i] = $_POST["axvalue"];
}
}
if (isset($_POST["nrange"]))
{
if($_POST["nrange"] > 0) $end = $_POST["nrange"];
if($end > 99999999999999999999) $end = 18;
}
if (isset($_POST["brange"]))
{
if($_POST["brange"] < $end) $begin = $_POST["brange"];
else $begin = 0;
}
if (isset($_POST["visual"]))
{
if($_POST["visual"] == "true") { $visualchecked = "checked"; $jarray = $XXA;}
}
if(isset($_POST["axvalue"]) && !isset($_POST["visual"]))
{
$visualchecked = "";
$jarray = 3; // limited visual view
}
else if(!isset($_POST["axvalue"]) && !isset($_POST["visual"]))
{
$visualchecked = "checked";
$jarray = $XXA;
}
//****************************
//Calculation form
//****************************
echo "<table><tr><td>Prime number finding...<br/><br/><br/>\n";
echo '<form name="htmlform" method="post" id="prime.number" action="">';
echo '<hr><br/><strong><a title="-n to n">ax</a></strong> start value : <input value="'.$areax[0].'"
type="text" name="axvalue" maxlength="20" size="6"> ';
echo '<strong><a
title="-n to -1
-1 to -0.01 (change resolution)
0
0.01 to 1 (change resolution)
1 to n">..0</a></strong> range : <input value="'.$begin.'"
type="text" name="brange" maxlength="15" size="6"> ';
echo '<strong><a
title="1 to n
">..n</a></strong> range : <input value="'.$end.'"
type="text" name="nrange" maxlength="15" size="6"> ';
echo '<input type="submit" value="Calculate primes">';
echo '<input type="checkbox" id=visual="yes" name="visual" '.$visualchecked.'
value="true">show with detailed visual representation</input><br/><br/>';
echo '</form>';
echo "<hr><font face='arial,helvetica' size='3'><strong>Prime =
(ax:$areax[0])+(((0..n:$begin..$end)+1)*2)+((((0..n:$begin..$end)*2)-1)*2)
= Ax, Ay or Az</strong></font><hr>";
//****************************
//****************************
if($beginrange == 0)$beginrange = 1;
else if($beginrange >= 1)$beginrange = 1;
else if($beginrange <= -1)$beginrange = 1;
else if($beginrange > -1 && $beginrange < 0)$beginrange *= -1;
for( $i = $begin; $i <= $end; $i = $i + $beginrange )
{
$superb2 = 0;
$ipop = 0;
$ipush = 0;
while( $ipush < $XXA )
{
$XAREA[$ipush] = $areax[$ipush] + ( ( ( $i + $ipop ) + 1 ) * 2 ) + ( ( ( ( $i + $ipop ) * 2 ) - 1 ) * 2 ); $ipush++;
$XAREA[$ipush] = $areax[$ipush] + ( ( ( $i + $ipop ) + 1 ) * 2 ) ; $ipush++;
$XAREA[$ipush] = $areax[$ipush] + ( ( ( ( $i + $ipop ) * 2 ) - 1 ) * 2 ); $ipush++;
$ipop++;
$XAREA[$ipush] = $areax[$ipush] - ( ( $i + $ipop ) * 2 ) - ( ( ( ( $i + $ipop) * 2 ) - 1 ) * 2 ); $ipush++;
$XAREA[$ipush] = $areax[$ipush] - ( ( $i + $ipop ) * 2 ) ; $ipush++;
$XAREA[$ipush] = $areax[$ipush] - ( ( ( ( $i + $ipop ) * 2 ) - 1 ) * 2 ); $ipush++;
$ipop++;
}
if($visualchecked != "checked")
{
if(is_prime($areax[0]))
{
echo "<font face='arial,helvetica' color='#FFD801'><strong>".$areax[0]."</strong></font>
+ ( ( $i + 1 ) * 2 ) + ( ( ( $i * 2 ) - 1 ) * 2 ) = ";
}
else
{
echo "$areax[0] + ( ( $i + 1 ) * 2 ) + ( ( ( $i * 2 ) - 1 ) * 2 ) = ";
}
}
for($j = 0 ; $j < $jarray; $j++)
{
for($jcolor = 0; $jcolor < $jarray; $jcolor++)
if($j == $jcolor)
{
if($visualchecked != "checked")
{
if( ($j % 3) == 0){ $color = "red"; $prexfix = " AX: ";}
else if( ($j % 3) == 1){ $color = "lightgreen"; $prexfix = " AY: ";}
else if( ($j % 3) == 2){ $color = "blue"; $prexfix = " AZ: ";}
}
else
{
$prexfix = "";
$color = rand_color();
}
break;
}
$prime_check = $XAREA[($j)];
if(is_prime($prime_check))
{
if($visualchecked == "checked")
{
//**************************
//draw text visualation
//**************************
if($prime_check < 0)$prime_check *= -1;
echo $prexfix.'<font face="arial,helvetica" size="2"
color="'.$color.'"><strong><a title="'.$prime_check.' is a prime number."
alt="'.$prime_check.' is a prime number.">O</a></strong></font>'; // O
//**************************
//**************************
//**************************
//draw picture visualation
//**************************
//
//**************************
//**************************
}
else
{
//**************************
//draw text visualation
//**************************
if($prime_check < 0)$prime_check2 = -1 * $prime_check;
else $prime_check2 = $prime_check;
echo $prexfix.'<font face="arial,helvetica" size="2"
color="'.$color.'"><strong> <a title="'.$prime_check2.' is a prime number."
alt="'.$prime_check2.' is a prime number.">'.$prime_check.'</a>
</strong> </font>';
//**************************
//**************************
}
$superb++;
$superb2++;
}
else
{
if($visualchecked == "checked")
{
echo $prexfix.'<font face="arial,helvetica" size="2"
color="white"><strong>Ø</strong></font>'; // Ø
//**************************
//draw picture visualation
//**************************
//
//**************************
//**************************
}
else
{
echo $prexfix.'<font face="arial,helvetica" size="2"
color="black"> '.$prime_check.'
</font> ';
}
}
}
echo "<br/>\n";
$ipush = $ipop = 0;
while( $ipush < $XXA)
{
$areax[$ipush] = $XAREA[$ipop]; $ipush++;
$areax[$ipush] = $XAREA[$ipop]; $ipush++;
$areax[$ipush] = $XAREA[$ipop]; $ipush++;
$ipop = $ipop + 3;
}
$endcount++;
}
//****************************
//Time exucution for algoritm end time
//****************************
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
//echo "Executed in ".$totaltime." seconds";
//****************************
$c = $endcount / 100;
$percentage = floor($superb / $c);
echo '<hr><br/><br/><strong> Total prime count : </strong><font face="arial,helvetica" size="3"
color="red"><strong>'.$superb.' / '.$endcount.'
</strong></font> , %'.$percentage.' percentage, executed in '.$totaltime.' seconds<br/>';
echo "<br/><br/>
*******************************************************<br/>
****** About Formula ********************************<br/>
*******************************************************<br/>
***** The above formula, the prime numbers in numbers plane<br/>
***** Ax, Ay or Az. Results obtained from the above formula,<br/>
***** which will be advantageous to use the unit automatically<br/>
***** shows the analytical plane. Vector in the first series<br/>
***** of the formula, primes numbers say bid welcome to us.<br/>
***** <br/>
****** 3L+4L tangential<br/>
****** 4L+3L tangential<br/>
****** 3L+2L+3L semicircle<br/>
****** 3L+4L+3L+4L rectangle<br/>
****** 5L + in center 4L perpendicular<br/>
********************************************************<br/>
<br/>
Prime numbers that can be called to create a unique geometric <br/>
shapes and planes. Therefore, it is difficult to find<br/>
the prime numbers with a simple method. As consisting of <br/>
prime numbers, numbers, geometric shapes, and the plane can be<br/>
divided into only their coats. Therefore, you should look at <br/>
a number can create unique geometric shapes to create a unique<br/>
checking the inertness. Primes are special, try to understand it <br/>
helps to understand the math, and even provides even of<br/>
mathematical development. For example, to invent systems that <br/>
can be found prime numbers of its number in numeretical system.<br/>
<br/>
Important topics in this so primality:<br/>
* Lack of self divisor other numbers.<br/>
* Unique dimentional plane that can be created.<br/>
* Unique geometric shape that can be created.<br/>
* Angular, linear, area measurement accuracy.<br/>
<br/>
Sample:<br/>
34 numbers divisible only 17 and 2, and unique heptadecagon, <br/>
17 is no integer divisor in lower group. 38 numbers<br/>
divisible only 19 and 2, and unique enneadecagon, 19 is no integer <br/>
divisor in lower group.<br/><br/><a alt='Prime Numbers Methodology'
title='Prime Numbers Methodology' target='_blank'
href='img/template/design1/spiral.helix.area.prime.png'>Show methodology
of analysis is how it works...</a> and source code<br/><br/><br/><br/>
</td></tr></table>";
?>