Giter VIP home page Giter VIP logo

Hi there 👋

  • 📫 How to reach me: Send me a quick github message or reach me by mail. 😉
  • 😄 Pronouns: she/her
  • ⚡ Fun fact: Did you know that you can calculate the modulo of two numbers $n$ and $d$ by doing modulo reductions by $b$, which you can simply set to a power of two. This allows you to calculate modulo with only bitshifting, additions and a multiplication. Anyways, here is an example:
fn fmod(n: u32, d: u32) -> u32 
{
	// Check if n is less than d first
	if n < d { return n; }
	
	// Find a suitable p for our base
	for p in 2..32 {
		if 1 << p > n { 
            // Will always find a p.
			return fmod_p(n, d, p)
		}
	}
	unreachable!(); // Mark as unreachable
}

fn fmod_p(n: u32, d: u32, p: u32) -> u32
{
	if n < 1 << p {
		if n < d { return n; }
		if n < d << 1 { return n - d; }
		return fmod_p(n, d, p-1);
	}
	
	fmod_p(
		((1 << p) - d) * (n >> p) + (n & ((1 << p) - 1)),
		d,
		p
	)
} 

fn main() {
	// Simple fizzbuzz example
	for i in 1..101 {
		let mut s = String::new();
		if fmod(i, 3) == 0 { s.push_str("Fizz"); }
		if fmod(i, 5) == 0 { s.push_str("Buzz"); }
		if s.is_empty() { s.push_str(&i.to_string()); }
		println!("{}", s);
	}
}

Phecda's Projects

acnh icon acnh

Animal Crossing New Horizons stuff

mhxqe icon mhxqe

A Monster Hunter X web based quest editor

ntrclient icon ntrclient

the NTR Debugger. [deprecated] Goto https://github.com/imthe666st/NTRSharp for the new project.

ntrsharp icon ntrsharp

Library for C# Applications that use NTR made by cell9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.