Hi Experts,
i am trying to make a program.
how to count string using Fibonacci numbers as numbers of strings over alphabets?
example: a=0,b=1 c=1,d=2,e=3,f=5,i=8..... like fibonacci series in alphabet order and end use put a string like : eidc
its sum count is 3+8+2+1=14
please help me.
Thanks & Regards
Ashish Sahu
its sum count is 3+8+2+1=14
please help me.
Thanks & Regards
Ashish Sahu

Ashish Sahu142 pointsPosted Aug 7, 2015, 5:22 AM EDT
class Fibonacci { static void Main(string[] args) { Dictionary<char, int> obj = new Dictionary<char, int>(); int n = 26, f = 1, k = -1, s = 0; for (int i = 0; i < n; i++) { s = k + f; k = f; f = s; int num = 65 + i; char c = (char)num; //Convert ASCII value into char int a = char.ToUpper('b');// convert char into ASCII value //Add values in to the dictionary obj.Add(c, s); //Console.WriteLine(s); } string str; str = Console.ReadLine().ToUpper(); int sum = 0; for (int j = 0; j < str.Length; j++) { sum = sum + obj[str[j]]; } Console.WriteLine(sum); Console.ReadLine(); } }