Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Fibonacci of array elements C#
//Microsoft (R) Visual C# Compiler version 3.4.0-beta4-19562-05 (ff930dec) //Copyright (C) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; namespace Rextester { public class Program { public static int fib(int cnt) { if (cnt <= 1) return cnt; else return (fib(cnt-1) + fib(cnt-2)); } public static void arrFib(int item) { for(int i=0; i <=item-1;i++) { int result = fib(i); if(i==item-1) { Console.WriteLine("Fibonacci of "+item.ToString()+" is "+result.ToString()); } } } public static void Main(string[] args) { int[] arr = new int[]{5,2,3,4,7,8,9,10,11,12,13,14,15,16}; List<int> listInt = arr.ToList(); Parallel.ForEach(listInt, l => { Program.arrFib(l); }); } } }
run
|
edit
|
history
|
help
0
rathit
Problem: rstring
test
Get a webpage - the sync way
Command design pattern
DotnetQ6
Math 12.2 Matrix Pool
time
oooo
Reflekcja assembly, instancja i metoda