I started learning python recently, so I used Project Euler to practice
Problem 1
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Run result: 233168
PHP version:
/** * @desc Project Euler 1 * @Author tina * @Date 2015-08-27 */ $sum = 0; for($i=0; $ipython version: <p></p><pre name="code">sum = 0 for i in range(1000): if((i%3 == 0) or (i%5 == 0)): sum += i print sum
Problem 2
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
Run result: 4613732
/** * @desc : Project Euler 2 * @Author : tina * @Date : 2015-08-27 */ $fab1 = 1; $fab2 = 1; $sum = 0; do{ $fab = $fab1+$fab2; $fab1 = $fab2; $fab2 = $fab; if($fab%2 == 0){ $sum += $fab; } }while($fab <br>Python version: <p></p><pre name="code">fab1 = 1 fab2 = 1 sum = 0 while True : fab = fab1+fab2 fab1 = fab2 fab2 = fab if(fab%2 == 0): sum += fab if(fab > 4000000) : break print sum
In fact, it feels generally the same... But after reading some python introductions, I feel that the functions are very powerful. Lists, dictionaries, and set data types can actually handle complex numbers! ! Looking forward to it! (PS: It seems that the great man who invented Python was born in mathematics, no wonder Luo!)
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the permission of the blogger.
The above introduces the implementation of Project Euler questions 1 and 2 in PHP and Python, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

机器之能报道编辑:吴昕国内版的人形机器人+大模型组队,首次完成叠衣服这类复杂柔性材料的操作任务。随着融合了OpenAI多模态大模型的Figure01揭开神秘面纱,国内同行的相关进展一直备受关注。就在昨天,国内"人形机器人第一股"优必选发布了人形机器人WalkerS深入融合百度文心大模型后的首个Demo,展示了一些有趣的新功能。现在,得到百度文心大模型能力加持的WalkerS是这个样子的。和Figure01一样,WalkerS没有走动,而是站在桌子后面完成一系列任务。它可以听从人类的命令,折叠衣物

如何在Excel中快速查看一列的总和如果您只想知道一列的总和而不需要将该信息添加到电子表格中,您可以使用Excel状态栏快速查看一列或任何单元格区域的总和。要使用Excel状态栏查看列的总和:突出显示要汇总的数据。要选择整个列,请单击列名。否则,拖动单元格以选择您的范围。在屏幕底部,您将看到有关您的选择的信息,例如所有值的平均值以及该范围内的数据点数。您还将看到所选单元格中所有值的总和。如何使用AutoSum在Excel中对列求和如果您希望将列的总和添加到电子表格中,在许多情况下

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于Seaborn的相关问题,包括了数据可视化处理的散点图、折线图、条形图等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于进程池与进程锁的相关问题,包括进程池的创建模块,进程池函数等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于数据类型之字符串、数字的相关问题,下面一起来看一下,希望对大家有帮助。

VS Code的确是一款非常热门、有强大用户基础的一款开发工具。本文给大家介绍一下10款高效、好用的插件,能够让原本单薄的VS Code如虎添翼,开发效率顿时提升到一个新的阶段。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于numpy模块的相关问题,Numpy是Numerical Python extensions的缩写,字面意思是Python数值计算扩展,下面一起来看一下,希望对大家有帮助。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Notepad++7.3.1
Easy-to-use and free code editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.