Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Part 1 - Using your Geometric Progression, write a script that verifies a Geometric progression with -1

1 answer below »
Part 1 - Using your Geometric Progression, write a script that verifies a Geometric
progression with -1< r < 1 and != 0 sum approaches ( starting_value / ( 1 - r ) ), allow the
user to enter an r value ( make sure to convert to a float ) and run until you are within
.00001 of the calculated sum, outputting the cu
ent sum in each iteration.
starting_value * r^nth-1 is each term
1st term is starting_value * r^0
2nd term is starting_value * r^1
3rd term is starting_value * r^2
Part 2 - Use the Fibonacci Progression to test the theory of number distribution
- https:
en.wikipedia.org/wiki/Benford%27s_law (Links to an external site.) grab the
first 500 values of Fibonacci and count the instances of each first digit ( the easy way is
to convert it to a string and grab the first character
https:
en.wikipedia.org/wiki/Benford%27s_law
Answered Same Day Jan 23, 2023

Solution

Vikas answered on Jan 24 2023
49 Votes
Assignment
PART – 1
starting_value = float(input("Enter the starting value: "))
= float(input("Enter the common ratio (make sure it is between -1 and 1 and not 0): "))
# Initialize variables
cu
ent_sum = starting_value
n = 0
# Loop until the cu
ent sum is within 0.00001 of the calculated sum
while abs(cu
ent_sum - (starting_value / (1 - r))) > 0.00001:
cu
ent_sum += starting_value * (r ** n)
n += 1
print("Cu
ent sum:", cu
ent_sum)
# Output the final sum
print("Final sum:", cu
ent_sum)
This script prompts the user to enter the starting value and...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here