Write the algorithm and the python code

Assignment Help Basic Computer Science
Reference no: EM132816770

Develop a python program Write the algorithm and the Python code to implement a solution to the following problem.

A magic square is an arrangement of numbers in a square grid, where the numbers in each row, each column, and each diagonal all add up to the same number ... that number is called a magic constant. The value of the magic constant, M, associated with a square that has n rows and columns is given by the formula:

M = n * (n2 + 1) / 2

The smallest possible magic square is a 3x3 grid, i.e., the above formula is only meaningful for n >= 3. In other words:

  • the 1st magic square is a 3x3 grid (n = 3; M = 15)
  • the 2nd magic square is a 4x4 grid (n = 4; M = 34)
  • etc.

Your program should ask the user how many magic constants to display, validate that the user has entered a positive integer, calculate the requested constants, and print the result in exactly the following format. For example, if the user enters 4, your message should say:

The first 4 magic constants are: 15, 34, 65, 111.

Reference no: EM132816770

Questions Cloud

What is the fund required rate of return : Required - If the market's required rate of return is 8% and the risk-free rate is 4%, what is the fund's required rate of return
Descriptive and predictive categories of data mining : What are FOUR differences between descriptive and Predictive categories of Data Mining.
Which is not disclosed on the statement of cash flows : Which is not disclosed on the statement of cash flows when prepared under the indirect method, either on the face of the statement or in a separate schedule?
How would you evaluate and manage a pediatric patient : How would you evaluate and manage a pediatric patient who has a painful swelling of the hands and feet, fatigue, or fussiness? Which diagnostic studies would.
Write the algorithm and the python code : Develop a python program Write the algorithm and the Python code to implement a solution to the following problem.
Prepare a report for CoffeeVille : Prepare a communication plan for the dissemination of information within the organisation. The communication plan should maintain effective workplace
Create strategy map for ajo medical center : Create a strategy map for the Ajo Medical Center as described in the discussion preparation.
Draw the truth table for the function h : For the following: h = w' x'yz' + wx' y' z' + wx'yz' + w'xyz' +wx'yz +w' x'yz +wxyz +w'xyz
Make journal entries to transfer loss to partners capital : Make journal entries to transfer the loss to the partners' capital accounts based on the No mention of profit/loss agreement agreements.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Offensive and defensive plan against future threat

Identify Millennium Healthcare Enterprise (MHE) weakness, if any. Identify the scope of offensive and defensive plan against future threat.

  What are privacy issues with data mining

Why are the original/raw data not readily usable by analytics tasks? What are the privacy issues with data mining? Do you think they are substantiated?

  Compare the accuracy of the derivative computatio

Compare the accuracy of the derivative computation using the central difference formula and the complex variable formula against the analytical value of the derivative of the test function

  Developing complete disaster recovery plan

You will be developing a complete Disaster Recovery Plan to be submitted to the executive board of your company.

  Most useful measure of network costs

How does network cost of ownership (aka real TCO) differ from total cost of ownership? Which is the most useful measure of network costs from the point of view of the network manager? Why?

  Analytical strengths and limitations in explaining economic

Understand the underlying axiom of rationality as self interest and evaluate its analytical strengths and limitations in explaining economic behaviour.

  Types of signal fading models

Explain why do we need two types of signal fading models (large scale and small scale).

  Health information professional

As a health information professional, you have been hired to consult a network of providers in the technology infrastructure supporting coordination of career

  Identify minimum of two additional network devices

What are some of the Security Basics when it comes to workstations and ways to secure Server environments - Identify a minimum of two additional Network Devices and ways to secure the devices?

  Safe and comfortable accommodation

When a guest stays at a hotel, they are, at-the-minimum, promised a clean, safe and comfortable accommodation. In addition, depending on the type of hotel

  Coso framework of internal controls is practiced

The COSO framework of internal controls is practiced within companies around the world. The objectives of the COSO framework are closely related

  Third normal form

To take this motley crew of tables to Third Normal Form (3NF), we must now take 2NF tables and eliminate all transitive (i.e., hidden) dependencies.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd