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
| SitePoint Sponsor |
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
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.
hay thanks for reply.
actually these kind of questions comes in technical test. so i just wanted to see different patterns![]()



What the hell... are you talking about
[read: PHP Sec. | CSRF | PCRE Mods | Encryption | Form Proc. | File Val.]
[tools: PHPEd | PHP Docs | jQuery | CI | SwiftMailer | CKEditor | reCAPTCHA]
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 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));
Max Says...
http://maxmanders.co.uk



[read: PHP Sec. | CSRF | PCRE Mods | Encryption | Form Proc. | File Val.]
[tools: PHPEd | PHP Docs | jQuery | CI | SwiftMailer | CKEditor | reCAPTCHA]
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.
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
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.
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.
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
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