4031 views|4 replies

382

Posts

9

Resources
The OP
 

[Rust] Nothing to do at night, practice questions [Copy link]

I wonder if you have heard of Project Euler http://pe-cn.github.io/problems/

Randomly pick a question to play with, for example, you happen to pick 526

Let f(n) be the largest prime factor of n.

Let g(n) = f(n) + f(n+1) + f(n+2) + f(n+3) + f(n+4) + f(n+5) + f(n+6) + f(n+7) + f(n+8), which is the sum of the largest prime factors of nine consecutive numbers starting from n.

Let h(n) be the maximum value of g(k) in 2 ≤ k ≤ n.

The topic itself is simple and easy to implement

But it gets stuck as soon as it starts running. Apparently there is something wrong with the algorithm. Does anyone have any idea for solving this problem?

526.rs

556 Bytes, downloads: 0

This post is from Embedded System

Latest reply

Stuck? Isn't Rust supposed to be problem-free once it's compiled?   Details Published on 2024-6-25 11:52

1129

Posts

1

Resources
2
 

To be frank, was attracted by "nothing happened at night"!

Boss, are you testing the performance of the machine?

This post is from Embedded System
 
 

4

Posts

0

Resources
3
 

The maximum value of an unsigned 64 int is 4294967295. Have you ever counted how many zeros there are in h()?

This post is from Embedded System

Comments

u64 is only this small? I thought it could support up to 2 to the power of 64...  Details Published on 2024-6-11 23:49
 
 
 

382

Posts

9

Resources
4
 
tang5722917 posted on 2024-6-11 17:16 The maximum value of an unsigned 64 int is 4294967295. Have you ever counted how many zeros there are in h()?

u64 is only this small? I thought it could support up to 2 to the power of 64...

This post is from Embedded System
 
 
 

7462

Posts

2

Resources
5
 

Stuck? Isn't Rust supposed to be problem-free once it's compiled?

This post is from Embedded System
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list