Septanet Forum  

Go Back   Septanet Forum > Computers, Software, Harware, Information Technology > PHP Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 08-08-2011, 10:06 AM   #1
Senior Member
 
sharma.s.prakash's Avatar
 
Join Date: Aug 2011
Posts: 110
Smile Pprint Fabonici series using PHP

printing fabonici series with using for loop
PHP Code:
$varFirst=0;
$varSecond=1;
$varSum=0;
echo 
$varFirst ', ';
echo 
$varSecond ', ';
while (
$varSum <= 55) {
   
    
$varSum $varFirst $varSecond;
    if (
$varSum >= 55) {
        echo 
$varSum;
        break;
    } else {
        echo 
$varSum.', ';
    }
    
    
$varFirst=$varSecond;
    
$varSecond=$varSum;

output: 0,1,1,2,3,5,8,13,21,34, 55
sharma.s.prakash is offline  
Digg this Post!Bookmark Post in Technorati
Reply With Quote
Old 08-08-2011, 10:54 AM   #2
Senior Member
 
kaman's Avatar
 
Join Date: Aug 2011
Posts: 111
Thumbs up

Like it. where in the programming we need such functionality? any idea?
kaman is offline  
Digg this Post!Bookmark Post in Technorati
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 12:53 PM.


Content Relevant URLs by vBSEO 3.5.0 RC2