NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

using System;

class Program
{
static void Main()
{
// Zadanie 1: Użytkownik podaje liczbę elementów do wygenerowania
Console.WriteLine("Zadanie 1: Podaj liczbę elementów do wygenerowania w ciągu Fibonacciego:");
int count = int.Parse(Console.ReadLine());

if (count <= 0)
{
Console.WriteLine("Podaj prawidłową liczbę elementów (większą od 0).");
return;
}

FibonacciIterative fibonacciIterative = new FibonacciIterative();
fibonacciIterative.Generate(count);

// Zadanie 2: Użytkownik podaje dwie liczby
Console.WriteLine("nZadanie 2: Podaj indeks początkowy (L1) ciągu Fibonacciego:");
int L1 = int.Parse(Console.ReadLine());

Console.WriteLine("Podaj liczbę elementów do wygenerowania (L2):");
int L2 = int.Parse(Console.ReadLine());

if (L1 < 0 || L2 <= 0)
{
Console.WriteLine("Podaj prawidłowe wartości: indeks początkowy musi być nieujemny, a liczba elementów dodatnia.");
return;
}

FibonacciUserInput fibonacciUserInput = new FibonacciUserInput();
fibonacciUserInput.Generate(L1, L2);
}
}

using System;

class FibonacciUserInput
{
public void Generate(int start, int count)
{
Console.WriteLine($"Generowanie ciągu Fibonacciego od indeksu {start} przez {count} elementów:");

for (int i = start; i < start + count; i++)
{
Console.Write(Calculate(i) + (i < start + count - 1 ? ", " : "n"));
}
}

private int Calculate(int n)
{
if (n <= 1) return n;

int a = 0, b = 1, c = 0;
for (int i = 2; i <= n; i++)
{
c = a + b;
a = b;
b = c;
}
return c;
}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.