SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Thread: numbers pattern

  1. #1
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    numbers pattern

    hello,

    I am looking for some complicated pattern as output and there solution, can anyone know here where i can get these patterns

    ex:--this is the simple one

    1
    1 2
    1 2 3 4 5

    but i want some complicated pattern and there solutions.

    thanks in advance

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,109
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Huh?

    What about Project Euler?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hay thanks for reply.

    actually these kind of questions comes in technical test. so i just wanted to see different patterns

  4. #4
    SitePoint Evangelist simshaun's Avatar
    Join Date
    Apr 2008
    Location
    North Carolina
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What the hell... are you talking about

  5. #5
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    simshaun, if you don't understand leave it or ask properly. this forum is about to solve problems only,so one should get equal chance to ask the query, the way they are facing it. please use proper language here.

  6. #6
    SitePoint Addict mmanders's Avatar
    Join Date
    Jul 2006
    Location
    Edinburgh, Scotland
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps simshaun posed the question poorly. In any case, I think perhaps deepson2 could have posed the question less ambiguously. My understanding is that deepson2 wants one or more PHP functions that model some classic mathematical series, for example, the fibonacci series:

    Code:
    function fibonacci($terms = 20)
    {
        list($cur, $nxt, $inc, $seq) = array(0, 1, 1, array());
        
        do
        {
            $inc++;
            $seq[] = $cur;
            $add = $cur + $nxt;
            $cur = $nxt;
            $nxt = $add;
        }
        while ($inc <= $terms);
        
        return $seq;
    }
    
    // First 50 terms in the fibonacci series
    print_r(fibonacci(50));

  7. #7
    SitePoint Evangelist simshaun's Avatar
    Join Date
    Apr 2008
    Location
    North Carolina
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deepson2 View Post
    simshaun, if you don't understand leave it or ask properly. this forum is about to solve problems only,so one should get equal chance to ask the query, the way they are facing it. please use proper language here.
    Perhaps you could try posting the question in a way that everyone can understand it... and by the way, my language is proper.

  8. #8
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks mmanders,

    for understanding my question, you are right.you have written here function for fibonacci series like wise i was looking for different series.. Next time i will post my query with more proper description.

  9. #9
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,049
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Deepson2, The issue is that the pattern you gave could have alot of different ways to accomplish it - and further down the sequence the outcomes can be very different.

    Maybe it means for each new row, have the previous row count plus the total amount of existing numbers?

    In which case the sequence would be, in a larger sense:
    1
    1 2
    1 2 3 4 5
    1 2 3 4 5 6 7 8 9 10 11 12 13
    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

    Without knowing what you're actually looking for, it can be anyone's guess what the solution is
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  10. #10
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey arkinstall, i am big fan of yours!!

    actually i was showing one example like this. i think, my question was wrong.
    now see, you have given the example of one sequence. so like that there are lots of series we can make. so i was just trying to ask here that can anyone knows more of diff series?

    more ex:-
    1
    1 2

    1 2 3

    1 2

    1
    Last edited by deepM; Feb 17, 2009 at 06:37.

  11. #11
    Always learning viveknarula's Avatar
    Join Date
    Mar 2006
    Location
    INDIA
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deepson2 View Post
    hey arkinstall, i am big fan of yours!!

    actually i was showing one example like this. i think, my question was wrong.
    now see, you have given the example of one sequence. so like that there are lots of series we can make. so i was just trying to ask here that can anyone no more of diff series?

    more ex:-
    1
    1 2

    1 2 3

    1 2

    1
    For different kind of patterns there will be different functions and logic so i think you should post full details of series you would like to program with PHP

  12. #12
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually i am looking for different patterns only(may be with functions also). i know we can make it different patterns. but still if i get some pattern as example here that will be more appropriated.

  13. #13
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,049
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Okkkk then.

    Well, now you say it it's hard to think of any.

    For the one you used:

    PHP Code:
    <?php
    function PrintPyramid($MaxNumber){
        
    $RowArray = Array();
        For(
    $i 1$i <= $MaxNumber$i++){
            
    $RowArray[] = range(1$i);
        }
        For(
    $i -= 3$i >= 0$i--){
            
    $RowArray[] = $RowArray[$i];
        }
        ForEach(
    $RowArray as $Row){
            echo 
    implode("\t"$Row) . '<br />';
        }
    }
    PrintPyramid(40);
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  14. #14
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the code. but this is the function. i am looking for more patterns actually. but anyways, your code is helpful, with this i ll try different patterns by myself. thank you.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •