1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anettt [7]
3 years ago
12

Write program to calculate the sum of the following series where in is input by user. (1/1 + 1/2 + 1/3 +..... 1/n)

Computers and Technology
1 answer:
Lorico [155]3 years ago
3 0

Answer:

#here is code in Python.

#read the value n from user

n=int(input("enter the value of n:"))

#variable to store the total sum

sum_n=0

for i in range(1,n+1):

# find the sum of series

   sum_n=sum_n+1/i

#print the sum

print("sum of the series is: ",sum_n)

Explanation:

Read the value of n from user. Create and initialize a variable sum_n with 0. Run a for loop to calculate sum.Initially sum_n is 0, then for value of i=1  1/i will be added to the sum_n.Then in next iteration for i=1, 1/2 added to sum_n. Similarly loop will run util i equals to n.Then sum_n will store the sum of the

series.

Output:

enter the value of n:5

sum of the series is:  2.283333333333333

You might be interested in
Write a function called median, that takes as parameter a full, sorted array of doubles and returns the median of the list. For
trapecia [35]

Answer:

Explanation:

public class Lab8

{

public static double median(double list[])

{

int size=list.length;

if(size%2!=0)

return list[size/2];

else

return(list[size/2-1]+list[size/2])/2.0;

}

public static boolean issorted(double list[])

{

for(int i=0;i<list.length-1;i++)

{

if(list[i]>list[i+1])

return false;

}

return true;

}

public static void findcommon(int a1[],int a2[],int common[])

{

int c=0;

for(int i=0;i<a1.length;i++)

{

boolean isFilled=false;

for(int j=0;j<c;j++)

{

if(a1[i]==common[j])

{

isFilled=true;

break;

}

}

if(isFilled)

{

for(int k=0;k<a2.length;k++)

{

if(a1[i]==a2[i])

{

common[c]=a1[i];

c++;

break;

}

}

}

}

while(c<common.length)

{

common[c]=0;

c++;

}

}

public static void rotateRight(int list[])

{

int temp=list[list.length-1];

for(int i=list.length-1;i>0;i--)

{

list[i]=list[i-1];

}

list[0]=temp;

}

public static int count(int list[],int n)

{

int ncount=0;

for(int i=0;i<list.length;i++)

{

if(list[i]==n)

ncount++;

}

return ncount;

}

public static int[] stretch(int list[])

{

int stretchedList[]=new int[list.length*2];

int k=0;

for(int i=0;i<list.length;i++)

{

int n=list[i];

if(n%2==0)

{

stretchedList[k]=n/2+1;

stretchedList[k+1]=n/2;

}

k+=2;

}

return stretchedList;

}

public static void printDoubleArray(double arr[])

{

System.out.print("[");

for(int i=0;i<arr.length;i++)

{

if(i!=arr.length-1)

System.out.print(arr[i]+",");

else

System.out.print(arr[i]);

}

System.out.println("]");

}

public static void printIntArray(int arr[])

{

System.out.print("[");

for(int i=0;i<arr.length;i++)

{

if(i!=arr.length-1)

System.out.print(arr[i]+",");

else

System.out.print(arr[i]);

}

System.out.println("]");

}

public static void main(String[] args)

{

double list1[]={1.1,2.2,3.3,4.4,5.5,6.6};

double med=median(list1);

System.out.println("List1:");

printDoubleArray(list1);

System.out.println("Median of List1:"+ med);

double list2[]={1.1,2.2,3.3,4.4,6.6,5.5};

boolean result=issorted(list2);

System.out.println("List2:");

printDoubleArray(list2);

System.out.println("List2 is a sorted array.(T/F):"+ result);

int list3[]={3,8,5,6,5,8,9,2};

int list4[]={5,15,4,6,7,3,9,11,9,3,12,13,14,9,5,3,13};

int list5[]=null;

if(list3.length<=list4.length)

list5=new int[list3.length];

else

list5=new int[list4.length];

findcommon(list3,list4,list5);

System.out.println("\n List3:");

printIntArray(list3);

System.out.println("\n List4:");

printIntArray(list4);

System.out.println("\n Array with common value,List5:");

printIntArray(list5);

int list6[]={3,8,19,7};

System.out.println("\n List6:");

printIntArray(list6);

rotateRight(list6);

System.out.println("\n the array after rotate right:");

printIntArray(list6);

int list7[]={3,5,2,1,92,38,3,14,5,73};

int n=count(list7,3);

System.out.println("\n List7:");

printIntArray(list7);

System.out.println("\n the number of occurences of the value 3 in the list 7:"+ n);

int list8[]={18,7,4,24,11};

int list9[]=stretch(list8);

printIntArray(list8);

System.out.println("\n The array after stretching:");

printIntArray(list9);

}

}

8 0
3 years ago
The function below takes two parameters: a string parameter: csv_string and an integer index. This string parameter will hold a
irakobra [83]

Answer:

The complete function is as follows:

def get_nth_int_from_CSV(CSV_string, index):

   splitstring = CSV_string.split(",")

   print(int(splitstring[index]))

Explanation:

This defines the function

def get_nth_int_from_CSV(CSV_string, index):

This splits the string by comma (,)

   splitstring = CSV_string.split(",")

This gets the string at the index position, converts it to an integer and print the converted integer

   print(int(splitstring[index]))

3 0
3 years ago
g What advantage does a circuit-switched network have over a packet-switched network? What advantages does TDM have over FDM in
REY [17]

Answer:

Advantages of a circuit-switched network over a packet-switched network are:

  • In Circuit-switched networks, resources needed to provide communication between the end systems for the duration of the session are usually reserved unlike in packet-switched networks where they are not reserved.
  • Circuit-switched networks have faster communication, so they can be used for Voice/Video calls
  • Circuit-switched networks have less errors in communication
  • Circuit-switched networks are more suitable for real-time services. Packet-switched networks are simpler, more efficient, and less costly to implement. They also offer better sharing of transmission capacity than circuit-switched network

Advantages does TDM have over FDM in a circuit-switched network are;

  • In TDM,  all connections operate at the same frequency , but In FDM,   all connections operate at different frequencies
  • In TDM there is low interference between the signals that are being multiplexed as compared to FDM.
  • In TDM, bandwidth is saved by allocating time slots on demand dynamically
  • TDM systems are more flexible than FDM

4 0
3 years ago
Read 2 more answers
You have found statistics on the Internet that you would like to use in your speech.
miss Akunina [59]

Answer:

You cite them correctly and that the statistics are real.

Explanation:

5 0
3 years ago
Creating a chart using a spreadsheet Chart Wizard involves four steps. Which is the last step?
oksian1 [2.3K]
Hey there!

The correct answer to your question will be finding the location for the chart.

Creating a chart using a spreadsheet Chart Wizard involves four steps.
The last step is to find where the chart should be located.
After you are done following the steps of making it, you apply it to a location you find is best to put it.


Hope this helps you.
Have a great day! :)
8 0
3 years ago
Other questions:
  • Categories of general purpose application software and examples each​
    13·1 answer
  • _________ are represented using diamonds linked withparticipant ETs
    6·1 answer
  • Assume there is a variable , h already associated with a positive integer value. Write the code necessary to count the number of
    13·1 answer
  • Brainly wont show me the "I'm Done" button after an interactive ad, and I cant figure out why. I've watched the entire ad, click
    11·2 answers
  • What computer is designed to meet the computing needs of several people simultaneously in a small to medium-size business enviro
    5·1 answer
  • A company purchased a high-quality color laser printer to print color brochures and sales proposals. The printer is connected to
    5·1 answer
  • Hi whats airpods good for
    15·2 answers
  • A student opens a recently purchased software package and begins reading the enclosed materials. What information might be inclu
    6·1 answer
  • Cloud computing allows organizations to rent computing resources from providers instead of having their own locally managed ____
    7·1 answer
  • Which of the following declares an abstract method in an abstract Java class?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!