• Write a function that creates the following pattern, given the height (number of rows)

*
***
*****
*******
*********
*********
*******
******
***
*

· The Fibonacci sequence is defined by the following rule. The first two values in the sequence are 1 and 1. Every subsequent value is the sum of the two values preceding it. For example, the third value is 1 + 1 = 2, the fourth value is 1 + 2 = 3, and the fifth is 2 + 3 = 5. If fn denote the nth value in Fibonacci sequence, then

f1 = 1
f2 = 1
fn = fn –1 + f n-2 if n > 2

Save the value of f1 (the current fibonacci number) in a temporary
Add f0 and f1 and store the value in f1, the new fibonacci number
Store the value of the temporary in f0 so that f0 will contain the previous fibonacci number
Print, and then repeat this process

Recommended Answers

All 3 Replies

It looks like homework to me. What code do you have so far?
We don't do homework but help with code you already have.

for the 1st qustion i have done this:
Module M1
Sub Main()
For Row as integer = 0 to 10
For Col as integer = 0 to 10
If Col = Row or Col = 10 - Row Then
system.console.Write("*")
Else
system.console.Write(".")
End IF
Next Col
WriteLine()
Next Row
End Sub
End Module

its not a homework by the way>i just need help with these questions.. and the second one i didn't now how to do it..

For the second one I think u have 3 variables f1=1, f0=1 and temp, u store f1 in the temp, add f1 and f0 together, print the result and store it in f1, then store the temp value in f0. and u start over. for as long as you want it to go on.

If you follow these steps u should be able to figure it out even if Im missing something. Working through these things on paper always helped me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.