Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,23 +1,24 @@
#![feature(core)]
fn sumsqd(mut n: i32) -> i32 {
let mut sq = 0;
while n > 0 {
let d = n % 10;
sq += d*d;
n /= 10
sq += d * d;
n /= 10;
}
sq
}
use std::num::Int;
fn cycle<T: Int>(a: T, f: fn(T) -> T) -> T {
fn cycle<T, F>(a: T, f: F) -> T
where
T: Copy + PartialEq,
F: Fn(T) -> T,
{
let mut t = a;
let mut h = f(a);
while t != h {
t = f(t);
h = f(f(h))
h = f(f(h));
}
t
}
@ -27,10 +28,10 @@ fn ishappy(n: i32) -> bool {
}
fn main() {
let happy = std::iter::count(1, 1)
.filter(|&n| ishappy(n))
.take(8)
.collect::<Vec<i32>>();
let happy: Vec<i32> = (1..)
.filter(|&n| ishappy(n))
.take(8)
.collect();
println!("{:?}", happy)
println!("{:?}", happy);
}