Duplicate Question
The question on this page has been marked as a duplicate question.
Original Question
1. Elements – sequence-series outputting Write a program that prints the following elements: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19,...Asked by OLEBOGENG HERRY
                 Elements – sequence-series outputting 
Write a program that prints the following elements: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19,
(hereto referred to as elements) etc., up till a user-entered value. The program should
not print more than 10 numbers per line. The last line printed may be less than 10.
Apart from the first number and the last number, there should be a “,” separating all
the numbers. The last number on every line should have a “.” after it. Before exiting
it should also prints the sum of all elements : Calculate the sum of the items and enter
the result. For instance if the user entered 76 your output should be as follows
A sample run of your program should be as follows:
Enter your number ( >= 1 and <= 100) : 76 
Your sequence is
1, 3, 5, 7, 9, 11, 13, 15, 17, 19.
21,23, 25, 27, 29, 31, 33, 35, 37, 39.
41,43, 45, 47, 49, 51, 53, 55, 57, 59.
61,63, 65, 67, 69, 71, 73, 75.
The sum of the above elements 1444
[25 pts.]
            
        Write a program that prints the following elements: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19,
(hereto referred to as elements) etc., up till a user-entered value. The program should
not print more than 10 numbers per line. The last line printed may be less than 10.
Apart from the first number and the last number, there should be a “,” separating all
the numbers. The last number on every line should have a “.” after it. Before exiting
it should also prints the sum of all elements : Calculate the sum of the items and enter
the result. For instance if the user entered 76 your output should be as follows
A sample run of your program should be as follows:
Enter your number ( >= 1 and <= 100) : 76 
Your sequence is
1, 3, 5, 7, 9, 11, 13, 15, 17, 19.
21,23, 25, 27, 29, 31, 33, 35, 37, 39.
41,43, 45, 47, 49, 51, 53, 55, 57, 59.
61,63, 65, 67, 69, 71, 73, 75.
The sum of the above elements 1444
[25 pts.]
Answers
                    Answered by
            Matt
            
    what language? 
    
                    Answered by
            Matt
            
    def sum(number): # we are defining a function
a = 0 #defines a = 0 becuase we start at 0
in python
sum=0 # defines sum at zero
because we start at 0
while a<checked_input: #check everytime if the a is redefined if it still is true
sum = sum + (a+1)#combination of this line//gives the answer
a = a + 2 # and this line gives a odd number
return sum #sends answer
    
a = 0 #defines a = 0 becuase we start at 0
in python
sum=0 # defines sum at zero
because we start at 0
while a<checked_input: #check everytime if the a is redefined if it still is true
sum = sum + (a+1)#combination of this line//gives the answer
a = a + 2 # and this line gives a odd number
return sum #sends answer
                                                    There are no AI answers yet. The ability to request AI answers is coming soon!
                                            
                Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.