Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace WebApplication1
- {
- public partial class WebForm4 : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- // Faris Rasyid | 50421483
- SetFibonacci(4);
- SetFibonacci(10);
- SetFibonacci(7);
- }
- public int Fibonacci(int x)
- {
- if (x <= 0)
- {
- return 0;
- }
- else if (x == 1)
- {
- return 1;
- }
- return Fibonacci(x - 1) + Fibonacci(x - 2);
- }
- public void SetFibonacci(int PanjangDeret)
- {
- for (int i = 0; i < PanjangDeret; i++)
- {
- if (i == PanjangDeret - 1)
- {
- Response.Write(Fibonacci(i) + "<br/>");
- }
- else
- {
- Response.Write(Fibonacci(i) + ",");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement