Click here to Skip to main content
15,905,971 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI,

i have faced a question in interview that....
\
1)
finding the entered value is primenumber or not......?

and
2)Recursive Factorial

3)fibonacci series...
pls any one help me for these programs......
Posted

Google can be best place for these type of questions........
 
Share this answer
 
 
Share this answer
 
just take the logic:
for prime number:

use modulos(%) operator to find the remainder. If the remainder is 0 for more than one number then the number is not a prime number otherwise number is prime.

for Recursive factorial:

multiply the numbers less than that number (upto1)

for fibonacci series:

add 0&1 to get the 3rd number in the series,then add the result & previous number to get the 4th number, like this continue...


I think u will do best with this much......all the best
 
Share this answer
 
Fibonacci Series

C#
using System;
class Program
{
    static void Main()
    {
        int boyut;
        Console.Write("The number of serial:");
        int.TryParse(Console.ReadLine(), out boyut);


        int[] dizi = new int[boyut];

        dizi[0] = 1;
        dizi[1] = 1;

        for (int i = 2; i < boyut; i++)
            dizi[i] = dizi[i - 1] + dizi[i - 2];

        for (int i = 0; i < boyut; i++)
            Console.Write(dizi[i] + " - ");

        Console.ReadLine();
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900