finally
This commit is contained in:
49
FibonacciWindow.xaml.cs
Normal file
49
FibonacciWindow.xaml.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FibonacciWindow.xaml
|
||||
/// </summary>
|
||||
|
||||
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<long> list = new List<long>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user