arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1212.5645cs.DScs.CC
收藏

不用乘法求第一N个自然数平方的算法

Algorithm to Compute Squares of 1st N Natural Numbers Without Using Multiplication

Rajat Tandon

摘要:

处理器可能会发现一些基本操作比其他操作更快。虽然一个操作在概念上可能与其他操作一样简单,但两者的处理速度可能会有所不同。一个聪明的程序员总是试图选择更快的指令来完成任务。本文提出了一种不使用乘法(* 运算符)显示第1 ~ N个自然数平方的算法。相反,可以使用加法(+运算符)完成相同的工作。结果也可以用来计算这些平方和。如果我们将计算第一N个自然数平方的常规方法与该方法进行比较,我们可以得出结论,本文所讨论的算法在时间复杂度方面更优化。

英文摘要:

Processors may find some elementary operations to be faster than the others. Although an operation may be conceptually as simple as some other operation, the processing speeds of the two can vary. A clever programmer will always try to choose the faster instructions for the job. This paper presents an algorithm to display squares of 1st N natural numbers without using multiplication (* operator). Instead, the same work can be done using addition (+ operator). The results can also be used to compute the sum of those squares. If we compare the normal method of computing the squares of 1st N natural numbers with this method, we can conclude that the algorithm discussed in the paper is more optimized in terms of time complexity.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑