using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Lab
{
///
/// Interaction logic for FibonacciWindow.xaml
///
public partial class FibonacciWindow : Window
{
private void ClickBack(object sender, RoutedEventArgs e) => Close();
private void ClickCalc(object sender, RoutedEventArgs e)
{
OutBox.Text = "";
InfoText.Text = "";
if (!Parsers.TryParseInt(NBox.Text, out int n) || n <= 0) {
InfoText.Text = "Введите целое N, N > 0.";
return;
}
long a = 1;
long b = 1;
List list = new List();
while (a < n) { list.Add(a); long next = a + b; a = b; b = next; }
OutBox.Text = string.Join(", ", list);
InfoText.Text = $"Найдено чисел: {list.Count}.";
}
public FibonacciWindow()
{
InitializeComponent();
}
}
}