Yeay... Momo Lovers (LOL) :'D
It has been a long time since I've focused on something, I didn't create anything strange anymore here. :'D
While
I am preparing for something and then looking for some of basic
algorithm again like I used to do some years ago, I found about
Fibonacci Sequence Logic.
(As always, I immediately zonked out when learning something overnight -_- Zzzzz )
What is Fibonacci?
Fibonacci is the sequence that let each number value adding itself with the value preceding to it.
<?
$first=0;
$second=1;
echo "$first $second";
for($i=1; $i<=6; $i++)
{
$third=$a+$b;
$first=$second;
$second=$third;
echo "$third ";
}
?>
The result will be:
0 1 1 2 3 5
Showing posts with label Algorithm. Show all posts
Showing posts with label Algorithm. Show all posts
PHP Simple FIbonacci Script
Posted by
Dewi Mulyani
|
Tuesday, May 17, 2016
|
Labels:
Algorithm,
Technology,
Web programming
|
0
comments
Semester 1
Posted by
Dewi Mulyani
|
|
Labels:
Algorithm,
Course,
Introduction of information technology
|
0
comments
Types of algorithm structure
There're several kind of Algorithm Structure, such as Sequence, Selection, and Iteration with each sample.
you can download it on this link:
Algorithm Structure
you can download it on this link:
Algorithm Structure
converting decimal to binary, binary to octal, octal to decimal, hex to decimal, binary to hex, and binary to octal
A. Decimal to binary
Decimal has 10 digit numbers include 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and Binary has 2 digit numbers include 0 and 1.
How to convert Decimal to binary?
For example:
211(10) = .........(2)?
Answer:
211/2 = 105 rest 1
105/2 = 52 rest 1
52/2 = 26 rest 0
26/2 = 13 rest 0
13/2 = 6 rest 1
6/2 = 3 rest 0
3/2 = 1 rest 1
then arrange the rest from the bottom to up and be like this 1010011(2).
B. Binary to decimal
For example:
C. Binary to octal
Octal has 8 digit numbers include 0,1,2,3,4,5,6,7.
How to convert binary to octal 100001101111(2) = ..........(8)?
First, give bulkhead on each 3-digit numbers as below:
100(2) = 4(8)
001(2) = 1(8)
101(2) = 5(8)
111(2) = 7(8)
So, the octal numbers're 4157.
D. Octal to decimal
1124(8) = ..............(10)?
Answer:
=(1*8^3)+ (1*8^2)+ (2*8^1)+ (4*8^0)
=(1*512)+(1*64)+(2*8)+(4*1)
= 512+64+16+4
=596
D. Hex to decimal
Hex has more than 9 digit numbers.Include 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. A same with 10, B same with 11, C same with 12, D same with 13, E same with 14, and F same with 15.
How to convert DCB12(16) = ...............(10)?
Answer:
=(13*16^4)+(12*16^3)+(11*16^2)+(1*16^1)+(2*16^0)
= (13*65536)+(12*4096)+(11*256)+(1*16)+(2*1)
=851968+49152+2816+16+2
=903954
E. Biner to hex
How to convert 1101111000110101(2)=....................(16)
First, give bulkhead on each 4-digit numbers as below:
Just like above that i can share. Hopefully helpful
Decimal has 10 digit numbers include 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and Binary has 2 digit numbers include 0 and 1.
How to convert Decimal to binary?
For example:
211(10) = .........(2)?
Answer:
211/2 = 105 rest 1
105/2 = 52 rest 1
52/2 = 26 rest 0
26/2 = 13 rest 0
13/2 = 6 rest 1
6/2 = 3 rest 0
3/2 = 1 rest 1
then arrange the rest from the bottom to up and be like this 1010011(2).
B. Binary to decimal
For example:
C. Binary to octal
Octal has 8 digit numbers include 0,1,2,3,4,5,6,7.
How to convert binary to octal 100001101111(2) = ..........(8)?
First, give bulkhead on each 3-digit numbers as below:
100(2) = 4(8)
001(2) = 1(8)
101(2) = 5(8)
111(2) = 7(8)
So, the octal numbers're 4157.
D. Octal to decimal
1124(8) = ..............(10)?
Answer:
=(1*8^3)+ (1*8^2)+ (2*8^1)+ (4*8^0)
=(1*512)+(1*64)+(2*8)+(4*1)
= 512+64+16+4
=596
D. Hex to decimal
Hex has more than 9 digit numbers.Include 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. A same with 10, B same with 11, C same with 12, D same with 13, E same with 14, and F same with 15.
How to convert DCB12(16) = ...............(10)?
Answer:
=(13*16^4)+(12*16^3)+(11*16^2)+(1*16^1)+(2*16^0)
= (13*65536)+(12*4096)+(11*256)+(1*16)+(2*1)
=851968+49152+2816+16+2
=903954
E. Biner to hex
How to convert 1101111000110101(2)=....................(16)
First, give bulkhead on each 4-digit numbers as below:
Just like above that i can share. Hopefully helpful
Subscribe to:
Posts (Atom)