码迷,mamicode.com
首页 > 其他好文 > 详细

Project Euler 3

时间:2019-03-26 19:31:27      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:style   输入   mod   ase   while   for   printf   break   NPU   

Problem 3

The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

 Solve:

clear
clc
t = input(‘pelase input the number:‘); %输入任意一个正整数
for i = 2:t-1
while mod(t,i) == 0
t = t/i;
end
if t == 1;
a = i;
break
end
end
fprintf(‘The answer is %.0d\n‘,a)

Project Euler 3

标签:style   输入   mod   ase   while   for   printf   break   NPU   

原文地址:https://www.cnblogs.com/JerryBerry/p/10602712.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!