Skip to content

Commit

Permalink
Update some files
Browse files Browse the repository at this point in the history
  • Loading branch information
itsubaki committed Jun 5, 2024
1 parent 4c5e503 commit f593de8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shor"
version = "0.0.2"
version = "0.0.3"
license = "MIT"
authors = ["itsubaki"]
description = "Shor's factoring algorithm written in rust"
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ fn main() {
return;
}

if number::is_prime(n) {
println!("N={} is prime.", n);
if let Some((base, exp)) = number::base_exp(n) {
println!("N={}. N is exponentiation. {}^{}.", n, base, exp);
return;
}

if let Some((base, exp)) = number::base_exp(n) {
println!("N={}. N is exponentiation. {}^{}.", n, base, exp);
if number::is_prime(n) {
println!("N={} is prime.", n);
return;
};
}

let mut used = vec![];
loop {
Expand Down
2 changes: 1 addition & 1 deletion src/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub fn find_order(a: u32, n: u32, bin: &[char]) -> (u32, u32, bool) {
}

pub fn is_trivial(n: u32, factor: &[u32]) -> bool {
for (_, p) in factor.iter().enumerate() {
for p in factor.iter() {
if 1 < *p && *p < n && n % p == 0 {
return false;
}
Expand Down

0 comments on commit f593de8

Please sign in to comment.