Question

C# Help Please (Number one is below at the bottom) 1- Write a program that generates...

C# Help Please (Number one is below at the bottom)

1- Write a program that generates the following sequence using while loop

2, 3 , 6, 11, 18, 27, … , 102

2- A.    Repeat 1 using for loop.

B. Modify your program in A to skip 27 from that sequence.

C. Modify your program in A by using break statement to stop generating the sequence if the generated number is greater than 30.

3. Using loops, find the value of f(7) given:
f(0)=4,  
f(n) = 2f(n-1)+4, where n is Natural number

Hint:

f(1)=2f(0)+4= 2*4+4= 12

f(2)=2f(1)+4= 2*12+4=28

f(3)= 2f(2)+4= 2*28+4= 60

  
4. Using loops, find f(5) given:
f(0)=1, f(1) = 1
f(n) = 3f(n-1)f(n-2) +1, where n is Natural number

Hint:

f(2)=3f(1)f(0)+1= 3*1*1+1= 4

f(3)=3f(2)f(1)+1= 3*4*1+1= 13

f(4)=3f(3)f(2)+1= 3*13*4+1= 157

f(5)=3f(4)f(3)+1= 3*157*13+1= 6124


5. Using two nested for loops, generate the following
10 20 30 40 50 60
20 30 40 50 60
30 40 50 60
40 50 60
50 60
60

I started the first part.

using System;

public class SequenceWhile
{
    public static void Main(string[] args)
    {
        int i = 2, inc = 0;
        while (i <= 102)
        {
            Console.Write(i + ", ");
            i += 2*inc + 1;
            inc++;
        }
        Console.WriteLine();
    }
}

Can someone help me with the rest? Thank you.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System;

class MainClass {

public static void Main (string[] args) {

int i = 2, inc = 0;

while (i <= 102)

{

if(i != 27)

Console.Write(i + " ");

i += 2*inc + 1;

inc++;

}

Console.WriteLine();

}

}

/*

OUTPUT

2 3 6 11 18 38 51 66 83 102

*/

using System;

class MainClass {

public static void Main (string[] args) {

int i = 2, inc = 0;

while (i <= 102)

{

if(i > 30)

break;

if(i != 27)

Console.Write(i + " ");

i += 2*inc + 1;

inc++;

}

Console.WriteLine();

}

}

/*

OUTPUT

2 3 6 11 18

*/

using System;

class MainClass {

public static void Main (string[] args) {

int f = 4, n = 7;

for(int i=1; i<=n; i++)

f = 2*f + 4;

Console.WriteLine("f(7) = "+ f);

}

}

/*

OUTPUT: f(7) = 1020

*/

// 2 coding questions at a time please -- Policy of HomeworkLib. Answerd 2 and 3.

Add a comment
Know the answer?
Add Answer to:
C# Help Please (Number one is below at the bottom) 1- Write a program that generates...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C# Programming 1-Write a program that generates the following sequence using while loop 2, 3,6,11, 18,...

    C# Programming 1-Write a program that generates the following sequence using while loop 2, 3,6,11, 18, 27,... 102 2-A. Repeat 1 using for loop. B. Modify your program in A to skip 27 from that sequence. C. Modify your program in A by using break statement to stop generating the sequence if the generated number is greater than 30 3. Using loops, find the value of f(7) given: fO)-4, f(n) 2f(n-1)+4, where n is Natural number Hint: f(1)-2f(0)+4-2 4+4-12 f12)-2f(1)+4-...

  • 1. Write a program that randomly generates 10 whole numbers between 0 and 100 and stores...

    1. Write a program that randomly generates 10 whole numbers between 0 and 100 and stores them into an array. The program then calculates the average and displays the average and the numbers that are above the average. Use loops where needed. Must be stored in an array. Must be done using C++. 2. Write a program that reads 8 student scores, between 0 and 100, finds the best score, and then assigns grades based on the following scheme. Must...

  • please solve number 5 only #4 Find i(t) fort <0 and > 0 for the following...

    please solve number 5 only #4 Find i(t) fort <0 and > 0 for the following circuit (pts. 20) 1 = 0 40 Ω 30 Ω 20 V 3F: ΤΣ 0.5i 50 Ω #5. Determine vc, le and energy stored in the Capacitor and inductor in the following circuit under DC condition. 8 Ω (pts. 20) + Τι c 2F 10A 4Ω ele 0.5 Η 5Ω

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : i have 15 min to submit the solution please help me   You are given a sequence of n non-zero integers a1,a2,…,an. Determine if the given sequence contains a pair of adjacent elements of the same sign (both negative or both positive). Two elements are called adjacent if they stand next to each other...

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : You are given a sequence of n non-zero integers a1,a2,…,an. Determine if the given sequence contains a pair of adjacent elements of the same sign (both negative or both positive). Two elements are called adjacent if they stand next to each other in the sequence. Input The first line contains an integer n...

  • use Java please. The Fibonacci Sequence Given the initial Fibonacci numbers 0 and 1, we can...

    use Java please. The Fibonacci Sequence Given the initial Fibonacci numbers 0 and 1, we can generate the next number by adding the two previous Fibonacci numbers together. For this sequence, you will be asked to take an input, denoting how many Fibonacci numbers you want to generate. Call this input upperFibLimit. The longest Fib sequence you should generate is 40 and the shortest you should generate is 1. So,1<upperFibLimit<40 The rule is simple given f(0) 0, f(1) 1 ....

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : Alex got a sequence of n integers a1,a2,…,an as a birthday present. Alex doesn't like negative numbers, so he decided to erase the minus signs from all negative numbers. As a result, he got a sequence of non-negative numbers. Print the resulting sequence. For example, if the sequence is  1, 5, -3, 4,...

  • This needs to be in C++ please. 1. Write a program to produce an n times...

    This needs to be in C++ please. 1. Write a program to produce an n times multiplication table (n less than or equal to 10) using while loops. For example, if n is equal to four the table should appear as follows: 1 2 3 4 1 1 2 3 4 2 2 4 6 8 3 3 6 9 12 4 4 8 12 16

  • **write program in C what is not clear? 3. (50pts) Write a simple sequence-number system through...

    **write program in C what is not clear? 3. (50pts) Write a simple sequence-number system through which three concurrent processes, P, P2, and P3, each obtain unique integers in the range [, 500]. Use the fork) call to create P, P2, and P3. Given a file, F, containing single number, each process must perform the following steps: a a. Open F b. Read the sequence number N from the file c. Close F d. Output N and the process' PID...

  • Write a C program that generates a random number between 0 and 50. Then, the program...

    Write a C program that generates a random number between 0 and 50. Then, the program prompts for guesses until the user is correct, or has made 10 wrong guesses. After each guess, the program indicates whether the guess was too high, too low, or correct. Once the round has ended, either by a correct guess or by using up the 10 guesses, the program displays the current status.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT