Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions hw1/hw1.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "hw1", "hw1\hw1.fsproj", "{0D25A530-A669-4CFC-92DF-161703584B9A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0D25A530-A669-4CFC-92DF-161703584B9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D25A530-A669-4CFC-92DF-161703584B9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D25A530-A669-4CFC-92DF-161703584B9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D25A530-A669-4CFC-92DF-161703584B9A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
48 changes: 48 additions & 0 deletions hw1/hw1/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
open System

let factorial x =
if x < 0 then
raise (ArgumentException "n должно быть неотрицательным")
if x = 0 then
1
else
let rec factorialCount x i acc =
if x = i then
i * acc
else
factorialCount x (i + 1) (acc * i)
factorialCount x 1 1

let fibonacci n =
if n < 0 then
raise (ArgumentException "n должно быть неотрицательным")
else
let rec fibonacciCount number acc1 acc2 =
if number = n then
acc1
else
fibonacciCount (number + 1) acc2 (acc1 + acc2)
fibonacciCount 0 0 1

let reverseList list =
let rec reverseListMaker list listNew =
match list with
| [] -> listNew
| _ -> reverseListMaker (List.tail list) ((List.head list) :: listNew)
reverseListMaker list []

let makeList n m =
let rec countPower n m list =
if n = m then
list
else
countPower n (m - 1) (pown 2 m :: list)
countPower n (n + m) []

let findFirst list number =
let rec findElement list number i =
match list with
| [] -> raise(ArgumentException "Нет такого элемента в списке")
| h :: t when h = number -> i
| _ -> findElement (List.tail list) number (i + 1)
findElement list number 0
13 changes: 13 additions & 0 deletions hw1/hw1/hw1.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

</Project>