Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7192233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:53:54+00:00 2026-05-28T19:53:54+00:00

class Program { static void Main(string[] args) { Console.WriteLine(Fib 1: ); Console.ReadLine(); } long

  • 0
class Program
{

    static void Main(string[] args)
    {
        Console.WriteLine("Fib 1: ");

        Console.ReadLine();
    }
    long fibonacci1()
    {
        long a = 1, b = 2, c, answer = 0;
        for (int i = 0; answer < 4000000; i++)
        {
            c = a + b;
            if (c % 2 == 0)
            {
                answer += c;
            }
            a = b + c;
            if (a % 2 == 0)
            {
                answer += a;
            }
            b = a + c;
            if (b % 2 == 0)
            {
                answer += b;
            }
        }
        return answer;
    }

    void fibonacci2()
    {
        long[] y = new long [1000000];
        long x = 2;
        long a = y[x - 2] = 1;
        long b = y[x - 1] = 2;
        long n = y[x];
        long answer = 0;

        for (x=2; answer < 4000000; x++)
        {
            n = a + b;
            if(n % 2 == 0)
            {
                answer += n;
            }
        }
        Console.WriteLine("Fib 2: " + answer);
    }
}

This is what I came up with so far. I am trying to come up with 2 ways to come up with the answer.

1) How do you call the two methods?

2) What you guys think about the two ways? I couldn’t test it, but any advice or hints(if I am wrong) Don’t give me the answer:)


Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:53:55+00:00Added an answer on May 28, 2026 at 7:53 pm

    Make them both static functions like this:

    static long fibonacci1()
    {
      ...
      return answer;
    }
    
    static long fibonacci2()
    {
      ...
      return answer;
    }
    

    and call them from Main() like this:

    {
        long a1 = fibonacci1();
        long a2 = fibonacci2();
        Console.Writeline(...);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this code snippet: class Program { static void Main(string[] args) { Console.WriteLine(Test().ToString()); }
using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine(new
Code: using System; class Program { static void Main(string[] args) { Console.Write(20); int myAge
I have the following code: class Program { static void Main(string[] args) { Console.WriteLine(SqrtRoot(0));
Below is my code. class Program { static void Main(string[] args) { Console.WriteLine(Main thread
class Program { internal delegate int CallBack(int i); static void Main(string[] args) { CallBack
When debugging the following console program: class Program { static void Main(string[] args) {
class Program { static void Main(string[] args) { String value = Two; Type enumType
class Program { static void Main(string[] args) { List<Book> books = new List<Book> {
Consider the following code: class Program { static void Main(string[] args) { Department deathStar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.